Skip to content

Commit 3769b5a

Browse files
committed
Make nexus slot supplier optional for backwards compatibility
1 parent ed7fa0b commit 3769b5a

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

temporalio/worker/_tuning.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,15 @@ def create_resource_based(
391391
@staticmethod
392392
def create_fixed(
393393
*,
394-
workflow_slots: Optional[int],
395-
activity_slots: Optional[int],
396-
local_activity_slots: Optional[int],
397-
nexus_slots: Optional[int],
394+
workflow_slots: Optional[int] = None,
395+
activity_slots: Optional[int] = None,
396+
local_activity_slots: Optional[int] = None,
397+
nexus_slots: Optional[int] = None,
398398
) -> WorkerTuner:
399-
"""Create a fixed-size tuner with the provided number of slots. Any unspecified slots will default to 100."""
399+
"""Create a fixed-size tuner with the provided number of slots.
400+
401+
Any unspecified slot numbers will default to 100.
402+
"""
400403
return _CompositeTuner(
401404
FixedSizeSlotSupplier(workflow_slots if workflow_slots else 100),
402405
FixedSizeSlotSupplier(activity_slots if activity_slots else 100),
@@ -409,17 +412,20 @@ def create_fixed(
409412
@staticmethod
410413
def create_composite(
411414
*,
412-
workflow_supplier: SlotSupplier,
413-
activity_supplier: SlotSupplier,
414-
local_activity_supplier: SlotSupplier,
415-
nexus_supplier: SlotSupplier,
415+
workflow_supplier: Optional[SlotSupplier] = None,
416+
activity_supplier: Optional[SlotSupplier] = None,
417+
local_activity_supplier: Optional[SlotSupplier] = None,
418+
nexus_supplier: Optional[SlotSupplier] = None,
416419
) -> WorkerTuner:
417-
"""Create a tuner composed of the provided slot suppliers."""
420+
"""Create a tuner composed of the provided slot suppliers.
421+
422+
Any unspecified slot suppliers will default to :py:class:`FixedSizeSlotSupplier` with a capacity of 100.
423+
"""
418424
return _CompositeTuner(
419-
workflow_supplier,
420-
activity_supplier,
421-
local_activity_supplier,
422-
nexus_supplier,
425+
workflow_supplier or FixedSizeSlotSupplier(100),
426+
activity_supplier or FixedSizeSlotSupplier(100),
427+
local_activity_supplier or FixedSizeSlotSupplier(100),
428+
nexus_supplier or FixedSizeSlotSupplier(100),
423429
)
424430

425431
@abstractmethod

tests/worker/test_worker.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,7 @@ def release_slot(self, ctx: SlotReleaseContext) -> None:
577577
ss = ThrowingSlotSupplier()
578578

579579
tuner = WorkerTuner.create_composite(
580-
workflow_supplier=ss,
581-
activity_supplier=ss,
582-
local_activity_supplier=ss,
583-
nexus_supplier=ss,
580+
workflow_supplier=ss, activity_supplier=ss, local_activity_supplier=ss
584581
)
585582
async with new_worker(
586583
client,
@@ -616,10 +613,7 @@ def release_slot(self, ctx: SlotReleaseContext) -> None:
616613
ss = BlockingSlotSupplier()
617614

618615
tuner = WorkerTuner.create_composite(
619-
workflow_supplier=ss,
620-
activity_supplier=ss,
621-
local_activity_supplier=ss,
622-
nexus_supplier=ss,
616+
workflow_supplier=ss, activity_supplier=ss, local_activity_supplier=ss
623617
)
624618
async with new_worker(
625619
client,

0 commit comments

Comments
 (0)