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
The *pool* parameter accepts a pebble.ProcessPool_ object. If provided, the pool will be used to run the function instead of a dedicated process. The *name*, *daemon* and *context* parameters will be ignored.
Runs the decorated function in a concurrent thread, taking care of the results and error management.
39
41
@@ -43,11 +45,12 @@ Pebble aims to help managing threads and processes in an easier way. It wraps Py
43
45
44
46
The *daemon* parameter switches between daemon and non-daemon threads.
45
47
48
+
The *pool* parameter accepts a pebble.ThreadPool_ object. If provided, the pool will be used to run the function instead of a dedicated thread. The *name* and *daemon* parameters will be ignored.
The *pool* parameter accepts a pebble.ProcessPool_ object. If provided, the pool will be used to run the function instead of a dedicated process. The *name*, *daemon* and *context* parameters will be ignored.
Runs the decorated function in a concurrent thread, taking care of the results and error management.
67
72
@@ -71,10 +76,13 @@ Pebble aims to help managing threads and processes in an easier way. It wraps Py
71
76
72
77
The *daemon* parameter switches between daemon and non-daemon threads.
73
78
79
+
The *pool* parameter accepts a pebble.ThreadPool_ object. If provided, the pool will be used to run the function instead of a dedicated thread. The *name* and *daemon* parameters will be ignored.
A ThreadPool allows to schedule jobs into a Pool of Threads which will perform them concurrently.
@@ -474,6 +483,27 @@ If a `timeout` is provided, it will be applied to the whole chunk and not to the
474
483
475
484
assert list(future.result()) == elements
476
485
486
+
The `concurrent` and `asynchronous` decorators accept a *pool* parameter. This is useful to control how many instances of decorated functions can be run at the same time.
487
+
488
+
::
489
+
490
+
from concurrent.futures import wait
491
+
from pebble import concurrent, ProcessPool
492
+
493
+
pool = ProcessPool(max_workers=4)
494
+
495
+
@concurrent.process(pool=pool)
496
+
def function(arg, kwarg=0):
497
+
return arg + kwarg
498
+
499
+
futures = []
500
+
501
+
# Maximum 4 executions of `function` will be executed in parallel
0 commit comments