Skip to content

Commit

Permalink
Update parsl_coprocess.py to bring in ndcctools bugfixes (#2977)
Browse files Browse the repository at this point in the history
This file is generated by ndcctool's poncho but there is no build system in place to cause that to happen, so this PR does that manually.
  • Loading branch information
colinthomas-z80 authored Nov 23, 2023
1 parent 1ec6421 commit a8dc3b4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions parsl/executors/workqueue/parsl_coprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def main():
"port": s.getsockname()[1],
}
send_configuration(config)
abs_working_dir = os.getcwd()
while True:
s.listen()
conn, addr = s.accept()
Expand All @@ -76,7 +77,7 @@ def main():
# see if the user specified an execution method
exec_method = event.get("remote_task_exec_method", None)
print('Network function: recieved event: {}'.format(event), file=sys.stderr)
os.chdir(f"t.{task_id}")
os.chdir(os.path.join(abs_working_dir, f't.{task_id}'))
if exec_method == "thread":
# create a forked process for function handler
q = queue.Queue()
Expand Down Expand Up @@ -112,10 +113,22 @@ def main():
conn.sendall(size_msg.encode('utf-8'))
# send response
conn.sendall(response)
os.chdir("..")
break
except Exception as e:
print("Network function encountered exception ", str(e), file=sys.stderr)
response = {
'Result': f'network function encountered exception {e}',
'Status Code': 500
}
response = json.dumps(response).encode('utf-8')
response_size = len(response)
size_msg = "{}\n".format(response_size)
# send the size of response
conn.sendall(size_msg.encode('utf-8'))
# send response
conn.sendall(response)
finally:
os.chdir(abs_working_dir)
return 0
def name():
return 'parsl_coprocess'
Expand Down

0 comments on commit a8dc3b4

Please sign in to comment.