Skip to content

Commit

Permalink
attempt at fixing weird atexit bug
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenhaute committed Dec 12, 2023
1 parent 6c0a996 commit ce97e8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions psiflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import parsl
# def wait():
# print('asdlfkjaslkdf')
# import time
# time.sleep(3)
# #import parsl
# #parsl.wait_for_current_tasks()
#
# import atexit
# atexit.register(wait)

from .execution import ExecutionContextLoader, load_from_yaml # noqa: F401

load = ExecutionContextLoader.load
parse_config = ExecutionContextLoader.parse_config
context = ExecutionContextLoader.context
wait = parsl.wait_for_current_tasks
wait = ExecutionContextLoader.wait
6 changes: 4 additions & 2 deletions psiflow/execution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations # necessary for type-guarding class methods

import atexit
import copy
import logging
import math
Expand Down Expand Up @@ -447,7 +446,6 @@ def load(
)
path_context = path / "context_dir"
cls._context = ExecutionContext(config, definitions, path_context)
atexit.register(parsl.wait_for_current_tasks)
return cls._context

@classmethod
Expand All @@ -456,6 +454,10 @@ def context(cls):
raise RuntimeError("No ExecutionContext is currently loaded")
return cls._context

@classmethod
def wait(cls):
parsl.wait_for_current_tasks()


def load_from_yaml(path: Union[str, Path]) -> ExecutionContext:
assert ExecutionContextLoader._context is None # no previously loaded context
Expand Down

0 comments on commit ce97e8b

Please sign in to comment.