Permalink
Browse files

process_queue: Fix worker variable being accessed before initialization.

  • Loading branch information...
timabbott committed Jan 27, 2016
1 parent b347688 commit 7595e4b05fe69a786cf83cad9c8a77f6e47b2f0f
Showing with 7 additions and 7 deletions.
  1. +7 −7 zerver/management/commands/process_queue.py
@@ -23,19 +23,19 @@ def handle(self, *args, **options):
queue_name = options['queue_name']
worker_num = options['worker_num']
- def signal_handler(signal, frame):
- logger.info("Worker %d disconnecting from queue %s" % (worker_num, queue_name))
- worker.stop()
- sys.exit(0)
-
if not settings.USING_RABBITMQ:
logger.error("Cannot run a queue processor when USING_RABBITMQ is False!")
sys.exit(1)
+ logger.info("Worker %d connecting to queue %s" % (worker_num, queue_name))
+ worker = get_worker(queue_name)
+
+ def signal_handler(signal, frame):
+ logger.info("Worker %d disconnecting from queue %s" % (worker_num, queue_name))
+ worker.stop()
+ sys.exit(0)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
- logger.info("Worker %d connecting to queue %s" % (worker_num, queue_name))
- worker = get_worker(queue_name)
worker.start()

0 comments on commit 7595e4b

Please sign in to comment.