Skip to content

Commit

Permalink
avoid busy wait
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Jan 7, 2025
1 parent 34d46e3 commit 90832b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions e2e_tests/message_queues/redis/test_message_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def message_handler(message: QueueMessage) -> None:
)
start_consuming_callable = await mq.register_consumer(test_consumer, topic="test")
t = asyncio.create_task(start_consuming_callable())
await asyncio.sleep(1.0)

# produce a message
test_message = QueueMessage(type="test_message", data={"message": "this is a test"})
Expand Down
4 changes: 2 additions & 2 deletions llama_deploy/message_queues/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def start_consuming_callable() -> None:
decoded_message = json.loads(message["data"])
queue_message = QueueMessage.model_validate(decoded_message)
await consumer.process_message(queue_message)
await asyncio.sleep(0)
await asyncio.sleep(0.01)
finally:
return

Expand Down Expand Up @@ -165,7 +165,7 @@ async def cleanup_local(
for consumer_metadata in self._consumers.values():
if consumer_metadata.pubsub:
await consumer_metadata.pubsub.unsubscribe()
await consumer_metadata.pubsub.close()
await consumer_metadata.pubsub.aclose()

# Clear consumers
self._consumers = {}
Expand Down

0 comments on commit 90832b9

Please sign in to comment.