• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pyiron / executorlib / 11543722968

27 Oct 2024 08:52PM UTC coverage: 94.335% (-0.2%) from 94.509%
11543722968

push

github

web-flow
Cache: Implement resource dict for submit() (#451)

* Cache: Implement resource dict for submit()

* Reduce inputs

* bug fixes

8 of 10 new or added lines in 2 files covered. (80.0%)

816 of 865 relevant lines covered (94.34%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/executorlib/standalone/cache/spawner.py
1
import subprocess
1✔
2
import time
1✔
3
from typing import Optional
1✔
4

5

6
def execute_in_subprocess(
1✔
7
    command: list,
8
    task_dependent_lst: list = [],
9
    resource_dict: Optional[dict] = None,
10
) -> subprocess.Popen:
11
    """
12
    Execute a command in a subprocess.
13

14
    Args:
15
        command (list): The command to be executed.
16
        task_dependent_lst (list): A list of subprocesses that the current subprocess depends on. Defaults to [].
17
        resource_dict (dict): resource dictionary, which defines the resources used for the execution of the function.
18
                              Example resource dictionary: {
19
                                  cwd: None,
20
                              }
21

22
    Returns:
23
        subprocess.Popen: The subprocess object.
24

25
    """
26
    while len(task_dependent_lst) > 0:
1✔
27
        task_dependent_lst = [
1✔
28
            task for task in task_dependent_lst if task.poll() is None
29
        ]
30
    if resource_dict is None:
1✔
NEW
31
        resource_dict = {"cwd": None}
×
32
    elif len(resource_dict) == 0:
1✔
NEW
33
        resource_dict = {"cwd": None}
×
34
    return subprocess.Popen(command, universal_newlines=True, cwd=resource_dict["cwd"])
1✔
35

36

37
def terminate_subprocess(task):
1✔
38
    """
39
    Terminate a subprocess and wait for it to complete.
40

41
    Args:
42
        task (subprocess.Popen): The subprocess.Popen instance to terminate
43
    """
44
    task.terminate()
1✔
45
    while task.poll() is None:
1✔
46
        time.sleep(0.1)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc