-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
636 additions
and
464 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,55 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Callable, Any | ||
|
||
|
||
class IPool(ABC): | ||
|
||
@property | ||
@abstractmethod | ||
def name(self) -> str: | ||
raise NotImplementedError() | ||
|
||
@property | ||
@abstractmethod | ||
def num_active_tasks(self) -> int: | ||
raise NotImplementedError() | ||
|
||
@abstractmethod | ||
def shutdown(self): | ||
''' | ||
The pool waits for all tasks to complete and frees any resources such as threads in a thread pool | ||
''' | ||
raise NotImplementedError() | ||
|
||
@abstractmethod | ||
def wait_completion(self): | ||
''' | ||
Blocks until all tasks have completed | ||
''' | ||
raise NotImplementedError() | ||
|
||
@abstractmethod | ||
def add_task(self, name: str, func: Callable[..., Any], *args, **kwargs): | ||
''' | ||
Call a python function on the pool | ||
:param str name: Friendly name of the task. Non-unique | ||
:param function func: Python function pointer to invoke on the pool | ||
:returns: task object | ||
:rtype: task | ||
''' | ||
raise NotImplementedError() | ||
|
||
@abstractmethod | ||
def add_process(self, name: str, func: Callable[..., Any], *args, **kwargs): | ||
''' | ||
Invoke a process on the pool. This function creates a task using name and then invokes pythons subprocess | ||
:param str name: Friendly name of the task. Non-unique | ||
:param function func: Process name to invoke using subprocess | ||
:returns: task object | ||
:rtype: task | ||
''' | ||
raise NotImplementedError() |
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
Oops, something went wrong.