Skip to content
Snippets Groups Projects
Commit 065de2c1 authored by wactbprot's avatar wactbprot
Browse files

error branch at worker.relay

parent 1e28d087
No related branches found
No related tags found
No related merge requests found
......@@ -44,23 +44,34 @@ class Worker(System):
self.log.error("member var: work_on_line not set")
def relay_worker(self, task, line):
ok = False
req = requests.post(self.relay_url, data=json.dumps(task), headers = self.headers)
res = req.json()
if 'DocPath' in task:
self.aset('doc_path', line, task['DocPath'], expire=False)
ok = True
if 'Result' in res:
self.aset('result', line, res['Result'], expire=False)
ok = True
if 'ToExchange' in res:
self.aset('exchange', line, res['ToExchange'], expire=False)
ok = True
self.log.debug("values written")
self.r.publish('io', line)
if 'error' in res:
self.aset('error', line, res, expire=False)
self.log.error("receive error")
self.r.publish('error', line)
ok = False
if ok:
self.log.debug("values written")
self.r.publish('io', line)
else:
self.log.error("... try again")
self.relay_worker(self, task, line)
def wait_worker(self, task, line):
time.sleep(5)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment