|
31 | 31 |
|
32 | 32 | class AutoLockRenewer(object): # pylint:disable=too-many-instance-attributes
|
33 | 33 | """Auto renew locks for messages and sessions using a background thread pool.
|
| 34 | + When handling multiple messages or sessions concurrently, |
| 35 | + set `max_workers` high or pass a ThreadPoolExecutor with sufficient `max_workers`. |
34 | 36 |
|
35 | 37 | :param max_lock_renewal_duration: A time in seconds that locks registered to this renewer
|
36 | 38 | should be maintained for. Default value is 300 (5 minutes).
|
@@ -71,24 +73,6 @@ def __init__(
|
71 | 73 | executor: Optional[ThreadPoolExecutor] = None,
|
72 | 74 | max_workers: Optional[int] = None,
|
73 | 75 | ) -> None:
|
74 |
| - """Auto renew locks for messages and sessions using a background thread pool. It is recommended |
75 |
| - setting max_worker to a large number or passing ThreadPoolExecutor of large max_workers number when |
76 |
| - AutoLockRenewer is supposed to deal with multiple messages or sessions simultaneously. |
77 |
| -
|
78 |
| - :param max_lock_renewal_duration: A time in seconds that locks registered to this renewer |
79 |
| - should be maintained for. Default value is 300 (5 minutes). |
80 |
| - :type max_lock_renewal_duration: float |
81 |
| - :param on_lock_renew_failure: A callback may be specified to be called when the lock is lost on the renewable |
82 |
| - that is being registered. Default value is None (no callback). |
83 |
| - :type on_lock_renew_failure: Optional[LockRenewFailureCallback] |
84 |
| - :param executor: A user-specified thread pool. This cannot be combined with |
85 |
| - setting `max_workers`. |
86 |
| - :type executor: Optional[~concurrent.futures.ThreadPoolExecutor] |
87 |
| - :param max_workers: Specify the maximum workers in the thread pool. If not |
88 |
| - specified the number used will be derived from the core count of the environment. |
89 |
| - This cannot be combined with `executor`. |
90 |
| - :type max_workers: Optional[int] |
91 |
| - """ |
92 | 76 | self._executor = executor or ThreadPoolExecutor(max_workers=max_workers)
|
93 | 77 | # None indicates it's unknown whether the provided executor has max workers > 1
|
94 | 78 | self._is_max_workers_greater_than_one = None if executor else (max_workers is None or max_workers > 1)
|
|
0 commit comments