You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-61Lines changed: 66 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# PyExPool
2
2
3
-
A Lightweight Multi-Process Execution Pool to schedule Jobs execution with *per-job timeout*, optionally grouping them into Tasks and specifying optional execution parameters considering NUMA architecture:
3
+
A Lightweight Multi-Process Execution Pool to schedule Jobs execution with *per-job timeout*, optionally grouping them into Tasks and specifying optional execution parameters considering NUMA architecture peculiarities:
4
4
5
5
- automatic CPU affinity management and maximization of the dedicated CPU cache for a worker process
6
-
- automatic rescheduling and balancing (reduction) of the worker processes and on low memory condition for the in-RAM computations (requires [psutil](https://pypi.python.org/pypi/psutil), can be disabled)
7
-
- chained termination of related worker processes and jobs rescheduling to satisfy timeout and memory limit constraints
6
+
- automatic rescheduling and *load balancing* (reduction) of the worker processes and on low memory condition for the *in-RAM computations* (requires [psutil](https://pypi.python.org/pypi/psutil), can be disabled)
7
+
-*chained termination* of related worker processes and jobs rescheduling to satisfy *timeout* and *memory limit* constraints
8
8
- timeout per each Job (it was the main initial motivation to implement this module, because this feature is not provided by any Python implementation out of the box)
9
-
- onstart/ondone callbacks, ondone is called only on successful completion (not termination) for both Jobs and Tasks (group of jobs)
9
+
- onstart/ondone *callbacks*, ondone is called only on successful completion (not termination) for both Jobs and Tasks (group of jobs)
10
10
- stdout/err output, which can be redirected to any custom file or PIPE
11
11
- custom parameters for each Job and respective owner Task besides the name/id
12
12
@@ -16,16 +16,19 @@ Implemented as a *single-file module* to be *easily included into your project a
16
16
The main purpose of this single-file module is the **asynchronous execution of modules and external executables with cache / parallelization tuning and automatic balancing of the worker processes for the in-RAM computations**.
17
17
In case asynchronous execution of the *Python functions* is required and usage of external dependences is not a problem, or automatic jobs scheduling for in-RAM computations is not required, then more handy and straightforward approach is to use [Pebble](https://pypi.python.org/pypi/Pebble) library.
18
18
19
+
The load balancing is enabled when global variables `_LIMIT_WORKERS_RAM` and `_CHAINED_CONSTRAINTS` are set, jobs categories and relative size (if known) specified. The balancing is performed to use as much RAM and CPU resources as possible performing in-RAM computations and meeting timeout, memory limit and CPU cache (processes affinity) constraints. Large executing jobs are rescheduled for the later execution with less number of worker processes after the completion of smaller jobs. The number of workers is reduced automatically (balanced) on the jobs queue processing. It is recommended to add jobs in the order of the increasing memory/time complexity if possible to reduce the number of worker process terminations for the jobs execution postponing on rescheduling.
Flexible API provides *automatic CPU affinity management, maximization of the dedicated CPU cache, limitation of the minimal dedicated RAM per worker process, balancing of the worker processes and rescheduling of chains of related jobs on low memory condition for the in-RAM computations*, optional automatic restart of jobs on timeout, access to job's process, parent task, start and stop execution time and more...
53
+
Flexible API provides *automatic CPU affinity management, maximization of the dedicated CPU cache, limitation of the minimal dedicated RAM per worker process, balancing of the worker processes and rescheduling of chains of the related jobs on low memory condition for the in-RAM computations*, optional automatic restart of jobs on timeout, access to job's process, parent task, start and stop execution time and more...
51
54
`ExecPool` represents a pool of worker processes to execute `Job`s that can be grouped into `Tasks`s for more flexible management.
self.assertGreaterEqual(jmsDvs.tstop-jmsDvs.tstart, worktime) # Smaller size of the ralted chained job to the vioated origin should not cause termination
1380
1399
self.assertGreaterEqual(jms1.tstop-jms1.tstart, worktime) # Independent job should have graceful completion
1381
1400
self.assertFalse(jms1.proc.returncode) # Errcode code is 0 on the gracefull completion
1382
-
self.assertIsNone(jmsDvl1.tstart) # Postponed job should be terminated before being started by the chaned relation on the memory-violating origin
1401
+
if_CHAINED_CONSTRAINTS:
1402
+
self.assertIsNone(jmsDvl1.tstart) # Postponed job should be terminated before being started by the chained relation on the memory-violating origin
1403
+
self.assertIsNone(jmsDvl2.tstart) # Postponed job should be terminated before being started by the chained relation on the memory-violating origin
1383
1404
#self.assertLess(jmsDvl1.tstop - jmsDvl1.tstart, worktime) # Early termination by the chained retalion to the mem violated origin
1384
1405
self.assertGreaterEqual(jms2.tstop-jms2.tstart, worktime) # Independent job should have graceful completion
1385
-
self.assertIsNone(jmsDvl2.tstart) # Postponed job should be terminated before being started by the chaned relation on the memory-violating origin
0 commit comments