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: doc/index.rst
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,8 @@ Pebble aims to help managing threads and processes in an easier way. It wraps Py
33
33
34
34
The *context* parameter can be used to specify the multiprocessing.context_ object used for starting the process.
35
35
36
+
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.
@@ -43,6 +45,7 @@ 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.
46
49
47
50
`Asynchronous Module`
48
51
---------------------
@@ -61,6 +64,8 @@ Pebble aims to help managing threads and processes in an easier way. It wraps Py
61
64
62
65
The *context* parameter can be used to specify the multiprocessing.context_ object used for starting the process.
63
66
67
+
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.
@@ -71,6 +76,8 @@ 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.
80
+
74
81
75
82
`Pebble Module`
76
83
---------------
@@ -474,6 +481,27 @@ If a `timeout` is provided, it will be applied to the whole chunk and not to the
474
481
475
482
assert list(future.result()) == elements
476
483
484
+
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.
485
+
486
+
::
487
+
488
+
from concurrent.futures import wait
489
+
from pebble import concurrent, ProcessPool
490
+
491
+
pool = ProcessPool(max_workers=4)
492
+
493
+
@concurrent.process(pool=pool)
494
+
def function(arg, kwarg=0):
495
+
return arg + kwarg
496
+
497
+
futures = []
498
+
499
+
# Maximum 4 executions of `function` will be executed in parallel
0 commit comments