Skip to content

Commit

Permalink
Fix: unneccesary warning during async check
Browse files Browse the repository at this point in the history
  • Loading branch information
vutran1710 committed Mar 11, 2024
1 parent edf21e4 commit 8555053
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyrate-limiter"
version = "3.4.0"
version = "3.4.1"
description = "Python Rate-Limiter using Leaky-Bucket Algorithm"
authors = ["vutr <me@vutr.io>"]
license = "MIT"
Expand Down
6 changes: 5 additions & 1 deletion pyrate_limiter/abstracts/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from abc import abstractmethod
from collections import defaultdict
from inspect import isawaitable
from inspect import iscoroutine
from threading import Thread
from typing import Awaitable
from typing import Dict
Expand Down Expand Up @@ -130,7 +131,10 @@ def register(self, bucket: AbstractBucket, clock: AbstractClock):
assert self.clocks is not None
assert self.async_buckets is not None

if isawaitable(bucket.leak(0)):
try_leak = bucket.leak(0)

if iscoroutine(try_leak):
try_leak.close()
self.async_buckets[id(bucket)] = bucket
else:
self.sync_buckets[id(bucket)] = bucket
Expand Down

0 comments on commit 8555053

Please sign in to comment.