Skip to content

Commit

Permalink
Changed default retention_timeout to zero for `AsyncBackgroundBatch…
Browse files Browse the repository at this point in the history
…er` for backwards compatibility with `aiuti<0.9`
  • Loading branch information
aiudirog committed Jul 4, 2024
1 parent 2558f08 commit 475439a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions aiuti/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def async_background_batcher(
max_batch_size: int = 256,
max_concurrent_batches: int = 5,
batch_timeout: float = 0.05,
retention_timeout: float = 0.1,
retention_timeout: float = 0.,
) -> Union[
Callable[
[_BatchFunc[A_contra, R_co]],
Expand Down Expand Up @@ -1041,7 +1041,7 @@ def __init__(self,
max_batch_size: int = 256,
max_concurrent_batches: int = 5,
batch_timeout: float = 0.05,
retention_timeout: float = 0.1):
retention_timeout: float = 0.):
"""
:param func: Batch execution function
:param max_batch_size:
Expand Down Expand Up @@ -1094,11 +1094,14 @@ async def __call__(self,
try:
return await fut
finally:
self._loop.call_later(
self.retention_timeout,
self._retention_cache.pop,
key,
)
if self.retention_timeout > 0:
self._loop.call_later(
self.retention_timeout,
self._retention_cache.pop,
key,
)
else:
del self._retention_cache[key]

def _daemon_task(
self,
Expand Down

0 comments on commit 475439a

Please sign in to comment.