49
49
logger = logging .getLogger (__name__ )
50
50
51
51
52
- @dataclass
52
+ @dataclass ( frozen = True )
53
53
class PollerBehaviorSimpleMaximum :
54
54
"""A poller behavior that will attempt to poll as long as a slot is available, up to the
55
55
provided maximum. Cannot be less than two for workflow tasks, or one for other tasks.
@@ -59,11 +59,11 @@ class PollerBehaviorSimpleMaximum:
59
59
60
60
def _to_bridge (self ) -> temporalio .bridge .worker .PollerBehavior :
61
61
return temporalio .bridge .worker .PollerBehaviorSimpleMaximum (
62
- maximum = self .maximum
62
+ simple_maximum = self .maximum
63
63
)
64
64
65
65
66
- @dataclass
66
+ @dataclass ( frozen = True )
67
67
class PollerBehaviorAutoscaling :
68
68
"""A poller behavior that will automatically scale the number of pollers based on feedback
69
69
from the server. A slot must be available before beginning polling.
@@ -201,11 +201,16 @@ def __init__(
201
201
``max_concurrent_workflow_tasks``, ``max_concurrent_activities``, and
202
202
``max_concurrent_local_activities`` arguments.
203
203
204
+ Defaults to fixed-size 100 slots for each slot kind if unset and none of the
205
+ max_* arguments are provided.
206
+
204
207
WARNING: This argument is experimental
205
208
max_concurrent_workflow_task_polls: Maximum number of concurrent
206
209
poll workflow task requests we will perform at a time on this
207
210
worker's task queue.
208
211
212
+ If set, will override any value passed to ``workflow_task_poller_behavior``.
213
+
209
214
WARNING: Deprecated, use ``workflow_task_poller_behavior`` instead
210
215
nonsticky_to_sticky_poll_ratio: max_concurrent_workflow_task_polls *
211
216
this number = the number of max pollers that will be allowed for
@@ -218,6 +223,8 @@ def __init__(
218
223
poll activity task requests we will perform at a time on this
219
224
worker's task queue.
220
225
226
+ If set, will override any value passed to ``activity_task_poller_behavior``.
227
+
221
228
WARNING: Deprecated, use ``activity_task_poller_behavior`` instead
222
229
no_remote_activities: If true, this worker will only handle workflow
223
230
tasks and local activities, it will not poll for activity tasks.
@@ -284,8 +291,10 @@ def __init__(
284
291
deployment_config: Deployment config for the worker. Exclusive with `build_id` and
285
292
`use_worker_versioning`.
286
293
WARNING: This is an experimental feature and may change in the future.
287
- workflow_task_poller_behavior: Specify the behavior of workflow task polling
288
- activity_task_poller_behavior: Specify the behavior of activity task polling
294
+ workflow_task_poller_behavior: Specify the behavior of workflow task polling.
295
+ Defaults to a 5-poller maximum.
296
+ activity_task_poller_behavior: Specify the behavior of activity task polling.
297
+ Defaults to a 5-poller maximum.
289
298
"""
290
299
if not activities and not workflows :
291
300
raise ValueError ("At least one activity or workflow must be specified" )
@@ -448,6 +457,15 @@ def __init__(
448
457
build_id = build_id
449
458
)
450
459
460
+ if max_concurrent_workflow_task_polls :
461
+ workflow_task_poller_behavior = PollerBehaviorSimpleMaximum (
462
+ maximum = max_concurrent_workflow_task_polls
463
+ )
464
+ if max_concurrent_activity_task_polls :
465
+ activity_task_poller_behavior = PollerBehaviorSimpleMaximum (
466
+ maximum = max_concurrent_activity_task_polls
467
+ )
468
+
451
469
# Create bridge worker last. We have empirically observed that if it is
452
470
# created before an error is raised from the activity worker
453
471
# constructor, a deadlock/hang will occur presumably while trying to
0 commit comments