Add TestWorker queue processor.

TestWorker is for troubleshooting, and it simply appends lines to a file
in /tmp.

(imported from commit 96b646a193a5474f3222b41725742e359b5301ec)
This commit is contained in:
Steve Howell
2013-10-30 11:01:18 -04:00
parent d5b7cfd21a
commit d7d1888ce0
2 changed files with 15 additions and 0 deletions

View File

@@ -254,3 +254,15 @@ class DigestWorker(QueueProcessingWorker):
logging.info("Received digest event: %s" % (event,))
handle_digest_email(event["user_profile_id"], event["cutoff"])
@assign_queue('test')
class TestWorker(QueueProcessingWorker):
# This worker allows you to test the queue worker infrastructure without
# creating significant side effects. It can be useful in development or
# for troubleshooting prod/staging. It pulls a message off the test queue
# and appends it to a file in /tmp.
def consume(self, ch, method, properties, event):
fn = settings.ZULIP_WORKER_TEST_FILE
message = ujson.dumps(event)
logging.info("TestWorker should append this message to %s: %s" % (fn, message))
with open(fn, 'a') as f:
f.write(message + '\n')

View File

@@ -522,6 +522,9 @@ else:
QUEUE_ERROR_DIR = 'queue_error'
ZULIP_WORKER_TEST_FILE = '/tmp/zulip-worker-test-file'
if len(sys.argv) > 2 and sys.argv[0].endswith('manage.py') and sys.argv[1] == 'process_queue':
FILE_LOG_PATH = WORKER_LOG_PATH
else: