def _remove_session(sender, *args, **kwargs):
  if hasattr(sender, 'app'):  # sender is a celery task
    app = sender.app
    task = sender
  else:                       # sender is a flask application
    app = sender
    task = None
  try:
    kit = Kit()
  except KitError:            # probably in nosetests
    pass
  else:
    kit.on_teardown(app, task)
Globally namespaced function for signals to work.
dataset/ETHPy150Open mtth/kit/kit/base.py/_remove_session