]> git.za3k.com Git - mqlg.git/commitdiff
Fix listener and enqueue
authorZachary Vance <za3k@za3k.com>
Sat, 14 Aug 2021 20:30:59 +0000 (13:30 -0700)
committerZachary Vance <za3k@za3k.com>
Sat, 14 Aug 2021 20:30:59 +0000 (13:30 -0700)
main.py

diff --git a/main.py b/main.py
index c31d8967af67d95bd9e01a1ead4fb90f64ec6018..c1bda1f05eb86e06fe2de32227f260df7ed3bba3 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -53,7 +53,7 @@ def threaded_consumer(queue, response_queue, consumer_callback, threads=None):
     def _done_cb(channel, method, future):
         # Always executed on main thread
         response = future.result()
-        if response is not None:
+        if response is not None and response_queue is not None:
             with lib.timer("send-response 1/2", logging.warning):
                 channel.basic_publish(
                     exchange='',
@@ -168,7 +168,7 @@ def do_listen(message):
         logging.error("skipped {}".format(output_path))
     else:
         content = base64.b64decode(response["content"].encode('ascii'))
-        with open(output_file, "wb") as f:
+        with open(output_path, "wb") as f:
             f.write(content)
         logging.warning("saved {}".format(output_path))
 
@@ -215,11 +215,11 @@ if __name__ == '__main__':
         elif command == "listener":
             if len(args) != 0:
                 raise InvalidArguments()
-            threaded_consumer(module.QUEUE_RESP, do_listen, threads=threads)
+            threaded_consumer(module.QUEUE_RESP, None, do_listen, threads=threads)
         elif command == "enqueue":
             if len(args) != 0:
                 raise InvalidArguments()
-            enqueue_all(queue, module.generate_tasks())
+            enqueue_all(module.QUEUE, module.generate_tasks())
         elif command == "debug":
             if len(args) != 2:
                 raise InvalidArguments()