Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Redis polling to dedicated thread #5947

Closed
wants to merge 1 commit into from
Closed

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented Dec 31, 2024

This PR moves the Redis polling loop from the asyncio event loop to a dedicated thread, which should improve performance by not blocking the event loop.

Changes:

  • Add threading module and thread control event
  • Replace asyncio task with daemon thread for Redis polling
  • Use asyncio.run_coroutine_threadsafe for message processing from thread
  • Improve error handling and cleanup

The Redis polling now runs in its own thread while maintaining thread safety by scheduling message processing in the asyncio event loop.


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:3c3fbd6-nikolaik   --name openhands-app-3c3fbd6   docker.all-hands.dev/all-hands-ai/openhands:3c3fbd6

- Add threading module and thread control event
- Replace asyncio task with daemon thread for Redis polling
- Use asyncio.run_coroutine_threadsafe for message processing
- Improve error handling and cleanup
@rbren rbren marked this pull request as draft December 31, 2024 21:35
@rbren rbren closed this Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants