Chiamata di risposta

This commit is contained in:
2020-03-19 15:57:51 +01:00
parent 4402c0a68e
commit 89c8d8715c
3 changed files with 24 additions and 6 deletions
+1
View File
@@ -8,4 +8,5 @@
"queue_id": "queueObject",
"thr": "threadObject",
"port": "int"
}
}
-3
View File
@@ -63,9 +63,6 @@ if __name__ == '__main__':
queues_in = {}
queue_command = queue.Queue()
queue_out = queue.Queue()
django_addr = ("http://{}:{}/"
.format(os.getenv('DJANGO_HOST', '127.0.0.1'),
os.getenv('DJANGO_PORT')))
t_notify_django = threading.Thread(target=notifier.notifier,
args=[django_addr, queue_out, logger],
daemon=True)
+23 -3
View File
@@ -1,11 +1,17 @@
import requests
import time
import os
URL_ERR = 'tscprinter/errore/'
URL_EVENT = 'tscprinter/evento/'
URL_RESP = 'tscprinter/risposta/'
URL_RESPONSE = 'tscprinter/risposta/'
def notifier(django_addr, queue_out, logger):
django_addr = ("http://{}:{}/"
.format(os.getenv('DJANGO_HOST', '127.0.0.1'),
os.getenv('DJANGO_PORT')))
def notifier(queue_out, logger):
logger.warning("Notifier started")
while True:
msg = queue_out.get(block=True)
@@ -16,4 +22,18 @@ def notifier(django_addr, queue_out, logger):
riuscita = True
except Exception as e:
time.sleep(2)
print(e)
print(e)
def send_response(queue_out, ip, command, data):
resp= {
'ip': ip,
'comando': command,
'dati': data
}
msg = {
'url' : URL_RESPONSE,
'msg': resp
}
queue_out.put(msg)