Skip to content

Commit

Permalink
Check locked before time expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
janbjorge committed Jan 22, 2025
1 parent 2014e57 commit 340a2c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pgqueuer/buffers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def periodic_flush(self) -> None:
shutdown = asyncio.create_task(self.shutdown.wait())
pending = set[asyncio.Task]()
while not self.shutdown.is_set():
if helpers.utc_now() > self.next_flush and not self.lock.locked():
if not self.lock.locked() and helpers.utc_now() > self.next_flush:
self.tm.add(asyncio.create_task(self.flush()))
self.next_flush = helpers.utc_now() + helpers.timeout_with_jitter(self.timeout)

Expand Down Expand Up @@ -134,8 +134,8 @@ async def add(self, item: T) -> None:

if (
self.events.qsize() >= self.max_size
and helpers.utc_now() > self.next_flush
and not self.lock.locked()
and helpers.utc_now() > self.next_flush
):
self.tm.add(asyncio.create_task(self.flush()))

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 340a2c3

Please sign in to comment.