From: Zachary Vance Date: Sat, 14 Aug 2021 20:30:59 +0000 (-0700) Subject: Fix listener and enqueue X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=ae4d8b4a1e4222bbe44969995f2c57ff56cd634d;p=mqlg.git Fix listener and enqueue --- diff --git a/main.py b/main.py index c31d896..c1bda1f 100755 --- 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()