Skip to content

Commit

Permalink
Adding logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjorthmedh committed Dec 5, 2024
1 parent b43c753 commit fe56edd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions snudda/detect/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2616,15 +2616,23 @@ def setup_parallel(self, d_view=None):
try:
with d_view.sync_imports():
from snudda.detect.detect import SnuddaDetect

except Exception as e:
self.write_log("Error during sync_imports:")
self.write_log(str(e))

worker_errors = d_view.apply_sync(lambda: str(e)).values()

for engine_id, error in enumerate(worker_errors):
self.write_log(f"Engine {engine_id}: {error}")
cmd_errorstr = """
import os
import traceback
import uuid
import traceback
tstr = traceback.format_exc()
tmp = open(os.path.join(f"worker-error-file-{uuid.uuid4()}"), 'w')
tmp.write(f"Exception: {tstr}")
tmp.close()
"""
d_view.execute(cmd_errorstr, block=True)

raise # Re-raise the exception to stop the job

Expand Down

0 comments on commit fe56edd

Please sign in to comment.