fix: handle console logs in dedicated workers

This commit is contained in:
Ruben Fiszel
2023-11-11 13:39:06 +01:00
parent fdfb12fd5b
commit fa3efd3f60
4 changed files with 34 additions and 16 deletions
@@ -902,12 +902,12 @@ for line in sys.stdin:
if type(v).__name__ == 'bytes':
res[k] = to_b_64(v)
res_json = re.sub(replace_nan, ' null ', json.dumps(res, separators=(',', ':'), default=str).replace('\n', ''))
sys.stdout.write(res_json + "\n")
sys.stdout.write("wm_res:" + res_json + "\n")
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
tb = traceback.format_tb(exc_traceback)
err_json = json.dumps({{ "error": {{ "message": str(e), "name": e.__class__.__name__, "stack": '\n'.join(tb[1:]) }} }}, separators=(',', ':'), default=str).replace('\n', '')
sys.stdout.write(err_json + "\n")
sys.stdout.write("wm_res:" + err_json + "\n")
sys.stdout.flush()
"#,
);
@@ -947,6 +947,7 @@ for line in sys.stdin:
job_completed_tx,
token,
jobs_rx,
worker_name,
)
.await
}