Skip to content

Commit c07983c

Browse files
committed
Add docstring about reserve race case
1 parent 5d4d167 commit c07983c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

temporalio/bridge/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporalio/worker/_tuning.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ async def reserve_slot(self, ctx: SlotReserveContext) -> SlotPermit:
191191
The only acceptable exception to throw is :py:class:`asyncio.CancelledError`, as invocations of this method may
192192
be cancelled. Any other exceptions thrown will be logged and ignored.
193193
194+
It is technically possible but rare, during worker shutdown, for this method to be called and return a value,
195+
but the Rust Core may not have a chance to _observe_ that value. In such cases the returned permit will not be
196+
released. The permit will, however, be forgotten and python will garbage collect it. So if you use the same slot
197+
supplier over the lifetime of more than one worker and it is critically important for you to clean up some
198+
resources associated all permits you construct, then consider using a finalizer on your returned permits.
199+
194200
Args:
195201
ctx: The context for slot reservation.
196202

0 commit comments

Comments
 (0)