本文整理汇总了Python中celery.loaders.app.AppLoader.init_worker方法的典型用法代码示例。如果您正苦于以下问题:Python AppLoader.init_worker方法的具体用法?Python AppLoader.init_worker怎么用?Python AppLoader.init_worker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.loaders.app.AppLoader
的用法示例。
在下文中一共展示了AppLoader.init_worker方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_AppLoader
# 需要导入模块: from celery.loaders.app import AppLoader [as 别名]
# 或者: from celery.loaders.app.AppLoader import init_worker [as 别名]
class test_AppLoader(Case):
def setUp(self):
self.app = app_or_default()
self.loader = AppLoader(app=self.app)
def test_config_from_envvar(self, key="CELERY_HARNESS_CFG1"):
self.assertFalse(self.loader.config_from_envvar("HDSAJIHWIQHEWQU", silent=True))
with self.assertRaises(ImproperlyConfigured):
self.loader.config_from_envvar("HDSAJIHWIQHEWQU", silent=False)
os.environ[key] = __name__ + ".object_config"
self.assertTrue(self.loader.config_from_envvar(key))
self.assertEqual(self.loader.conf["FOO"], 1)
self.assertEqual(self.loader.conf["BAR"], 2)
os.environ[key] = "unknown_asdwqe.asdwqewqe"
with self.assertRaises(ImportError):
self.loader.config_from_envvar(key, silent=False)
self.assertFalse(self.loader.config_from_envvar(key, silent=True))
os.environ[key] = __name__ + ".dict_config"
self.assertTrue(self.loader.config_from_envvar(key))
self.assertEqual(self.loader.conf["FOO"], 10)
self.assertEqual(self.loader.conf["BAR"], 20)
def test_on_worker_init(self):
prev, self.app.conf.CELERY_IMPORTS = (self.app.conf.CELERY_IMPORTS, ("subprocess",))
try:
sys.modules.pop("subprocess", None)
self.loader.init_worker()
self.assertIn("subprocess", sys.modules)
finally:
self.app.conf.CELERY_IMPORTS = prev
示例2: test_AppLoader
# 需要导入模块: from celery.loaders.app import AppLoader [as 别名]
# 或者: from celery.loaders.app.AppLoader import init_worker [as 别名]
class test_AppLoader(Case):
def setUp(self):
self.app = app_or_default()
self.loader = AppLoader(app=self.app)
def test_config_from_envvar(self, key='CELERY_HARNESS_CFG1'):
self.assertFalse(self.loader.config_from_envvar('HDSAJIHWIQHEWQU',
silent=True))
with self.assertRaises(ImproperlyConfigured):
self.loader.config_from_envvar('HDSAJIHWIQHEWQU', silent=False)
os.environ[key] = __name__ + '.object_config'
self.assertTrue(self.loader.config_from_envvar(key))
self.assertEqual(self.loader.conf['FOO'], 1)
self.assertEqual(self.loader.conf['BAR'], 2)
os.environ[key] = 'unknown_asdwqe.asdwqewqe'
with self.assertRaises(ImportError):
self.loader.config_from_envvar(key, silent=False)
self.assertFalse(self.loader.config_from_envvar(key, silent=True))
os.environ[key] = __name__ + '.dict_config'
self.assertTrue(self.loader.config_from_envvar(key))
self.assertEqual(self.loader.conf['FOO'], 10)
self.assertEqual(self.loader.conf['BAR'], 20)
def test_on_worker_init(self):
prev, self.app.conf.CELERY_IMPORTS = \
self.app.conf.CELERY_IMPORTS, ('subprocess', )
try:
sys.modules.pop('subprocess', None)
self.loader.init_worker()
self.assertIn('subprocess', sys.modules)
finally:
self.app.conf.CELERY_IMPORTS = prev
示例3: test_AppLoader
# 需要导入模块: from celery.loaders.app import AppLoader [as 别名]
# 或者: from celery.loaders.app.AppLoader import init_worker [as 别名]
class test_AppLoader(AppCase):
def setup(self):
self.loader = AppLoader(app=self.app)
def test_on_worker_init(self):
self.app.conf.imports = ("subprocess",)
sys.modules.pop("subprocess", None)
self.loader.init_worker()
self.assertIn("subprocess", sys.modules)
示例4: setup
# 需要导入模块: from celery.loaders.app import AppLoader [as 别名]
# 或者: from celery.loaders.app.AppLoader import init_worker [as 别名]
class test_AppLoader:
def setup(self):
self.loader = AppLoader(app=self.app)
def test_on_worker_init(self):
self.app.conf.imports = ('subprocess',)
sys.modules.pop('subprocess', None)
self.loader.init_worker()
assert 'subprocess' in sys.modules
示例5: test_AppLoader
# 需要导入模块: from celery.loaders.app import AppLoader [as 别名]
# 或者: from celery.loaders.app.AppLoader import init_worker [as 别名]
class test_AppLoader(AppCase):
def setup(self):
self.loader = AppLoader(app=self.app)
def test_on_worker_init(self):
self.app.conf.CELERY_IMPORTS = ('subprocess', )
sys.modules.pop('subprocess', None)
self.loader.init_worker()
self.assertIn('subprocess', sys.modules)
示例6: test_AppLoader
# 需要导入模块: from celery.loaders.app import AppLoader [as 别名]
# 或者: from celery.loaders.app.AppLoader import init_worker [as 别名]
class test_AppLoader(AppCase):
def setup(self):
self.loader = AppLoader(app=self.app)
def test_on_worker_init(self):
prev, self.app.conf.CELERY_IMPORTS = (self.app.conf.CELERY_IMPORTS, ("subprocess",))
try:
sys.modules.pop("subprocess", None)
self.loader.init_worker()
self.assertIn("subprocess", sys.modules)
finally:
self.app.conf.CELERY_IMPORTS = prev
示例7: test_AppLoader
# 需要导入模块: from celery.loaders.app import AppLoader [as 别名]
# 或者: from celery.loaders.app.AppLoader import init_worker [as 别名]
class test_AppLoader(Case):
def setUp(self):
self.app = app_or_default()
self.loader = AppLoader(app=self.app)
def test_on_worker_init(self):
prev, self.app.conf.CELERY_IMPORTS = (
self.app.conf.CELERY_IMPORTS, ('subprocess', ))
try:
sys.modules.pop('subprocess', None)
self.loader.init_worker()
self.assertIn('subprocess', sys.modules)
finally:
self.app.conf.CELERY_IMPORTS = prev