コード例 #1
0
ファイル: worker.py プロジェクト: ofpiyush/hedwig-py
    def run(self):
        from hedwig.core.consumer import Consumer
        import django

        django.setup()
        from .settings import hedwig_settings

        self.hedwig_consumer = Consumer(hedwig_settings)
        LOGGER.info("Django Hedwig consumer: starting")
        self.hedwig_consumer.consume()
        LOGGER.info("Django hedwig consumer: stopped")
コード例 #2
0
ファイル: worker.py プロジェクト: ofpiyush/hedwig-py
class DjangoHedwigWorker(multiprocessing.Process):
    def __init__(self, *args, **kwargs):
        self.hedwig_consumer = None
        super(DjangoHedwigWorker, self).__init__(*args, **kwargs)

    def run(self):
        from hedwig.core.consumer import Consumer
        import django

        django.setup()
        from .settings import hedwig_settings

        self.hedwig_consumer = Consumer(hedwig_settings)
        LOGGER.info("Django Hedwig consumer: starting")
        self.hedwig_consumer.consume()
        LOGGER.info("Django hedwig consumer: stopped")

    def shutdown(self):
        LOGGER.info("Django Hedwig consumer: shutting down")
        if self.hedwig_consumer is not None:
            self.hedwig_consumer.shutdown()
        LOGGER.info("Django Hedwig consumer: shutdown complete")
コード例 #3
0
ファイル: hedwig.py プロジェクト: ofpiyush/hedwig-py
def start_consumer():
    consumer = Consumer(hedwig_settings)
    consumer.consume()