fix: resolve WebSim event loop conflict in Docker environments#1643
Merged
openminddev merged 3 commits intoOpenMind:mainfrom Jan 18, 2026
Merged
Conversation
The tick() method crashed with "This event loop is already running" when deployed in Docker containers, causing WebSocket state updates to fail and frontend to display "OM Agent Status: OFF". Root cause: Attempting to call run_until_complete() on an already running event loop (e.g., when uvicorn server is running). Solution: Check if the event loop is already running using loop.is_running(). If so, use asyncio.run_coroutine_threadsafe() to safely schedule the coroutine from the synchronous thread. Added a 1-second timeout to prevent blocking forever. Also removed the fallback loop.create_task() which was ineffective since the created task was never awaited. Closes OpenMind#1621 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removed redundant comments and improved docstrings for several methods in WebSim.py. Cleaned up initialization and server startup code for better readability and maintainability.
aydnOktay
pushed a commit
to aydnOktay/OM1
that referenced
this pull request
Jan 19, 2026
…ind#1643) * fix: resolve WebSim event loop conflict in Docker environments The tick() method crashed with "This event loop is already running" when deployed in Docker containers, causing WebSocket state updates to fail and frontend to display "OM Agent Status: OFF". Root cause: Attempting to call run_until_complete() on an already running event loop (e.g., when uvicorn server is running). Solution: Check if the event loop is already running using loop.is_running(). If so, use asyncio.run_coroutine_threadsafe() to safely schedule the coroutine from the synchronous thread. Added a 1-second timeout to prevent blocking forever. Also removed the fallback loop.create_task() which was ineffective since the created task was never awaited. Closes OpenMind#1621 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Refactor WebSim.py for clarity and improved docstrings Removed redundant comments and improved docstrings for several methods in WebSim.py. Cleaned up initialization and server startup code for better readability and maintainability. --------- Co-authored-by: coco <coco@cocodeMacBook-Pro.local> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: openmindev <boyuan.eth@gmail.com> Co-authored-by: openminddev <147775420+openminddev@users.noreply.github.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root Cause
Attempting to call
run_until_complete()on an already running event loop (e.g., when uvicorn server is running in Docker).Changes
loop.is_running()asyncio.run_coroutine_threadsafe()to safely schedule the coroutineloop.create_task()which was never awaitedTest plan
Closes #1621
🤖 Generated with Claude Code