-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workers count can be given at engine creation
- Loading branch information
Showing
3 changed files
with
47 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from capsul.api import Capsul | ||
import time | ||
|
||
def noop() -> None: | ||
pass | ||
|
||
def test_start_workers(): | ||
capsul = Capsul(database_path="") | ||
noop_executable = capsul.executable(noop) | ||
for wc in [3, 2, 1]: | ||
with capsul.engine(workers_count=wc) as engine: | ||
requested = engine.config.start_workers.get("count", 0) | ||
assert requested == wc | ||
noop_id = engine.start(noop_executable) | ||
for i in range(100): | ||
if engine.database.workers_count(engine.engine_id) == wc: | ||
break | ||
time.sleep(0.2) | ||
else: | ||
raise RuntimeError(f'expected {wc} workers to be created, got {engine.database.workers_count(engine.engine_id)}') | ||
engine.dispose(noop_id) | ||
for i in range(100): | ||
if engine.database.workers_count(engine.engine_id) == 0: | ||
break | ||
time.sleep(0.2) | ||
else: | ||
raise RuntimeError(f'expected workers to be stopped; running workers = {engine.database.workers_count(engine.engine_id)}') |