Skip to content

Commit

Permalink
Merge pull request #71 from OFFIS-DAI/fix-fd-70
Browse files Browse the repository at this point in the history
Fixes #70
  • Loading branch information
jsagerOffis authored Mar 11, 2024
2 parents 2c1a149 + 0a2770a commit 1765d97
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mango/util/scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,8 @@ def __init__(
] = []
self.clock = clock if clock is not None else AsyncioClock()
self._scheduled_process_tasks = []
self._process_pool_exec = concurrent.futures.ProcessPoolExecutor(
max_workers=num_process_parallel, initializer=_create_asyncio_context
)
self._num_process_parallel = num_process_parallel
self._process_pool_exec = None
self._suspendable = suspendable
self._observable = observable

Expand Down Expand Up @@ -633,6 +632,11 @@ def schedule_process_task(self, task: ScheduledProcessTask, src=None):
:type src: Object
"""

if self._process_pool_exec is None:
self._process_pool_exec = concurrent.futures.ProcessPoolExecutor(
max_workers=self._num_process_parallel,
initializer=_create_asyncio_context,
)
loop = asyncio.get_running_loop()
manager = Manager()
event = manager.Event()
Expand Down Expand Up @@ -866,4 +870,5 @@ def shutdown(self):
event.set()
for task, _, _, _ in self._scheduled_tasks:
task.close()
self._process_pool_exec.shutdown()
if self._process_pool_exec is not None:
self._process_pool_exec.shutdown()

0 comments on commit 1765d97

Please sign in to comment.