Chiamata di risposta
parent
4402c0a68e
commit
89c8d8715c
|
|
@ -8,4 +8,5 @@
|
|||
"queue_id": "queueObject",
|
||||
"thr": "threadObject",
|
||||
"port": "int"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -17,3 +23,17 @@ def notifier(django_addr, queue_out, logger):
|
|||
except Exception as e:
|
||||
time.sleep(2)
|
||||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue