def test_get_active_apps(self): self.assertTrue(list(_state._get_active_apps())) app1 = Celery(set_as_current=False) appid = id(app1) self.assertIn(app1, _state._get_active_apps()) del(app1) # weakref removed from list when app goes out of scope. with self.assertRaises(StopIteration): next(app for app in _state._get_active_apps() if id(app) == appid)
def test_get_active_apps(self): assert list(_state._get_active_apps()) app1 = self.Celery() appid = id(app1) assert app1 in _state._get_active_apps() app1.close() del (app1) gc.collect() # weakref removed from list when app goes out of scope. with pytest.raises(StopIteration): next(app for app in _state._get_active_apps() if id(app) == appid)
def test_get_active_apps(self): self.assertTrue(list(_state._get_active_apps())) app1 = self.Celery() appid = id(app1) self.assertIn(app1, _state._get_active_apps()) app1.close() del(app1) gc.collect() # weakref removed from list when app goes out of scope. with self.assertRaises(StopIteration): next(app for app in _state._get_active_apps() if id(app) == appid)
def __inner(fun): name = options.get("name") # Set as shared task so that unfinalized apps, # and future apps will load the task. connect_on_app_finalize(lambda app: app._task_from_fun(fun, **options)) # Force all finalized apps to take this task as well. for app in _get_active_apps(): if app.finalized: with app._finalize_mutex: app._task_from_fun(fun, **options) # Return a proxy that always gets the task from the current # apps task registry. def task_by_cons(): app = current_app() return app.tasks[name or app.gen_task_name(fun.__name__, fun.__module__)] return Proxy(task_by_cons)
def __inner(fun): name = options.get('name') # Set as shared task so that unfinalized apps, # and future apps will load the task. _shared_task(lambda app: app._task_from_fun(fun, **options)) # Force all finalized apps to take this task as well. for app in _get_active_apps(): if app.finalized: with app._finalize_mutex: app._task_from_fun(fun, **options) # Return a proxy that always gets the task from the current # apps task registry. def task_by_cons(): app = current_app() return app.tasks[ name or gen_task_name(app, fun.__name__, fun.__module__)] return Proxy(task_by_cons)