From d5684a43360da4041a8186d1b8199df16d88a5b3 Mon Sep 17 00:00:00 2001 From: Migatu Date: Tue, 9 Apr 2024 12:32:05 +0200 Subject: [PATCH] Testing --- bot.py | 2 +- communication_subroutine.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/bot.py b/bot.py index b8cebe2..4f21cf5 100644 --- a/bot.py +++ b/bot.py @@ -2229,7 +2229,7 @@ if __name__ == "__main__": logger.info("Starting discord bot") threads = [] threads.append(threading.Thread(target=client.run, args=(TOKEN,))) - threads.append(threading.Thread(target=communication_subroutine.comm_subroutine, args=(OUT_COMM_Q,IN_COMM_Q))) + #threads.append(threading.Thread(target=communication_subroutine.comm_subroutine, args=(OUT_COMM_Q,IN_COMM_Q))) for worker in threads: worker.start() for worker in threads: diff --git a/communication_subroutine.py b/communication_subroutine.py index 0298974..c254ee3 100644 --- a/communication_subroutine.py +++ b/communication_subroutine.py @@ -4,7 +4,7 @@ import json from flask import Flask, jsonify, request from waitress import serve - +from bot import IN_COMM_Q, OUT_COMM_Q HOST_ADDRESS = "192.168.1.191" PORT_ADDRESS = 5000 @@ -22,6 +22,7 @@ def answer_external_command(): # 200, #) #return return_data + IN_COMM_Q.put("Test") return jsonify("SUCCESS") @app.route("/conjurer", methods=["GET"]) @@ -46,22 +47,20 @@ def waitress_run(_logger): _logger.info("Attempt waitress") serve(app, host=HOST_ADDRESS, port=PORT_ADDRESS) -def scan_queue(comm_q,out_queue): +def scan_queue(): while True: - data = comm_q.get() + data = OUT_COMM_Q.get() print(data) - out_queue.put("Test") + IN_COMM_Q.put("Test") -def comm_subroutine(in_comm_q, out_com_q): - in_queue = in_comm_q - out_queue = out_com_q +def comm_subroutine(): logger = logging.getLogger('conjurer_musician') logger.setLevel(logging.DEBUG) logger.info("Started") threads = [] threads.append(threading.Thread(target=waitress_run, args=(logger,))) - threads.append(threading.Thread(target=scan_queue, args=(in_queue,out_queue))) + threads.append(threading.Thread(target=scan_queue,)) for worker in threads: worker.start()