Skip to content

Commit

Permalink
[fix] Wait for pub-sub messages to arrive (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Sep 25, 2024
1 parent 5bf6ca9 commit f4fa9ca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion fixcloudutils/redis/pub_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def __init__(self, redis: Redis, channel: str, handler: MessageHandler) -> None:
async def start(self) -> None:
async def read_messages(pubsub: PubSub) -> None:
while True:
msg = await pubsub.get_message(ignore_subscribe_messages=True)
# timeout: waiting time for a message to be received in seconds
msg = await pubsub.get_message(ignore_subscribe_messages=True, timeout=30)
try:
if msg is not None:
data = json.loads(msg["data"])
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "fixcloudutils"
version = "1.15.0"
version = "1.15.1"
authors = [{ name = "Some Engineering Inc." }]
description = "Utilities for fixcloud."
license = { file = "LICENSE" }
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def eventually(

@fixture
async def redis() -> AsyncIterator[Redis]:
backoff = ExponentialBackoff() # type: ignore
backoff = ExponentialBackoff()
redis = Redis(host="localhost", port=6379, db=0, decode_responses=True, retry=Retry(backoff, 10))
await redis.flushdb() # wipe redis
yield redis
Expand Down

0 comments on commit f4fa9ca

Please sign in to comment.