本文整理汇总了Python中celery.worker.WorkController.on_start方法的典型用法代码示例。如果您正苦于以下问题:Python WorkController.on_start方法的具体用法?Python WorkController.on_start怎么用?Python WorkController.on_start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.WorkController
的用法示例。
在下文中一共展示了WorkController.on_start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_start
# 需要导入模块: from celery.worker import WorkController [as 别名]
# 或者: from celery.worker.WorkController import on_start [as 别名]
def on_start(self):
if not self._custom_logging and self.redirect_stdouts:
self.app.log.redirect_stdouts(self.redirect_stdouts_level)
WorkController.on_start(self)
# this signal can be used to e.g. change queues after
# the -Q option has been applied.
signals.celeryd_after_setup.send(
sender=self.hostname, instance=self, conf=self.app.conf,
)
if getattr(os, 'getuid', None) and os.getuid() == 0:
warnings.warn(RuntimeWarning(
'Running the worker with superuser privileges is discouraged!',
))
if self.purge:
self.purge_messages()
# Dump configuration to screen so we have some basic information
# for when users sends bug reports.
sys.__stdout__.write(
str(self.colored.cyan(' \n', self.startup_info())) +
str(self.colored.reset(self.extra_info() or '')) + '\n'
)
self.set_process_status('-active-')
self.install_platform_tweaks(self)
示例2: on_start
# 需要导入模块: from celery.worker import WorkController [as 别名]
# 或者: from celery.worker.WorkController import on_start [as 别名]
def on_start(self):
if not self._custom_logging and self.redirect_stdouts:
self.app.log.redirect_stdouts(self.redirect_stdouts_level)
WorkController.on_start(self)
# this signal can be used to e.g. change queues after
# the -Q option has been applied.
signals.celeryd_after_setup.send(
sender=self.hostname, instance=self, conf=self.app.conf,
)
if getattr(os, 'getuid', None) and os.getuid() == 0:
accept_encoding = self.app.conf.CELERY_ACCEPT_CONTENT
if ('pickle' in accept_encoding or
'application/x-python-serialize' in accept_encoding):
if not C_FORCE_ROOT:
raise RuntimeError(ROOT_DISALLOWED)
warnings.warn(RuntimeWarning(ROOT_DISCOURAGED))
if self.purge:
self.purge_messages()
# Dump configuration to screen so we have some basic information
# for when users sends bug reports.
sys.__stdout__.write(
str(self.colored.cyan(' \n', self.startup_info())) +
str(self.colored.reset(self.extra_info() or '')) + '\n'
)
self.set_process_status('-active-')
self.install_platform_tweaks(self)
示例3: on_start
# 需要导入模块: from celery.worker import WorkController [as 别名]
# 或者: from celery.worker.WorkController import on_start [as 别名]
def on_start(self):
app = self.app
WorkController.on_start(self)
# this signal can be used to e.g. change queues after
# the -Q option has been applied.
signals.celeryd_after_setup.send(
sender=self.hostname, instance=self, conf=app.conf,
)
if self.purge:
self.purge_messages()
# Dump configuration to screen so we have some basic information
# for when users sends bug reports.
use_image = self._term_supports_images()
if use_image:
self.termimage(static.logo_as_base64())
print(safe_str(''.join([
string(self.colored.cyan(
' \n', self.startup_info(artlines=not use_image))),
string(self.colored.reset(self.extra_info() or '')),
])), file=sys.__stdout__)
self.set_process_status('-active-')
self.install_platform_tweaks(self)
if not self._custom_logging and self.redirect_stdouts:
app.log.redirect_stdouts(self.redirect_stdouts_level)
示例4: on_start
# 需要导入模块: from celery.worker import WorkController [as 别名]
# 或者: from celery.worker.WorkController import on_start [as 别名]
def on_start(self):
WorkController.on_start(self)
# apply task execution optimizations
trace.setup_worker_optimizations(self.app)
# this signal can be used to e.g. change queues after
# the -Q option has been applied.
signals.celeryd_after_setup.send(
sender=self.hostname, instance=self, conf=self.app.conf,
)
if getattr(os, 'getuid', None) and os.getuid() == 0:
warnings.warn(RuntimeWarning(
'Running celeryd with superuser privileges is discouraged!'))
if self.purge:
self.purge_messages()
# Dump configuration to screen so we have some basic information
# for when users sends bug reports.
print(str(self.colored.cyan(' \n', self.startup_info())) +
str(self.colored.reset(self.extra_info() or '')))
self.set_process_status('-active-')
self.setup_logging()
self.install_platform_tweaks(self)
示例5: on_start
# 需要导入模块: from celery.worker import WorkController [as 别名]
# 或者: from celery.worker.WorkController import on_start [as 别名]
def on_start(self):
if not self._custom_logging and self.redirect_stdouts:
self.app.log.redirect_stdouts(self.redirect_stdouts_level)
WorkController.on_start(self)
# this signal can be used to e.g. change queues after
# the -Q option has been applied.
signals.celeryd_after_setup.send(sender=self.hostname, instance=self, conf=self.app.conf)
if not self.app.conf.value_set_for("accept_content"):
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
if self.purge:
self.purge_messages()
# Dump configuration to screen so we have some basic information
# for when users sends bug reports.
print(
safe_str(
"".join(
[
string(self.colored.cyan(" \n", self.startup_info())),
string(self.colored.reset(self.extra_info() or "")),
]
)
),
file=sys.__stdout__,
)
self.set_process_status("-active-")
self.install_platform_tweaks(self)
示例6: on_start
# 需要导入模块: from celery.worker import WorkController [as 别名]
# 或者: from celery.worker.WorkController import on_start [as 别名]
def on_start(self):
app = self.app
WorkController.on_start(self)
# this signal can be used to, for example, change queues after
# the -Q option has been applied.
signals.celeryd_after_setup.send(
sender=self.hostname, instance=self, conf=app.conf,
)
if self.purge:
self.purge_messages()
if not self.quiet:
self.emit_banner()
self.set_process_status('-active-')
self.install_platform_tweaks(self)
if not self._custom_logging and self.redirect_stdouts:
app.log.redirect_stdouts(self.redirect_stdouts_level)