Skip to content

fix: resolve WebSim event loop conflict in Docker environments#1643

Merged
openminddev merged 3 commits intoOpenMind:mainfrom
wtoqxy0000:fix/issue-1621-websim-event-loop
Jan 18, 2026
Merged

fix: resolve WebSim event loop conflict in Docker environments#1643
openminddev merged 3 commits intoOpenMind:mainfrom
wtoqxy0000:fix/issue-1621-websim-event-loop

Conversation

@wtoqxy0000
Copy link
Copy Markdown
Contributor

Summary

  • Fixed WebSim crash with "This event loop is already running" error in Docker
  • This caused 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 in Docker).

Changes

  • Check if the event loop is already running using loop.is_running()
  • If running, use asyncio.run_coroutine_threadsafe() to safely schedule the coroutine
  • Added 1-second timeout to prevent blocking forever
  • Removed ineffective fallback loop.create_task() which was never awaited

Test plan

  • All 339 existing tests pass
  • Ruff linting passes
  • Tested locally - no more "This event loop is already running" warnings

Closes #1621

🤖 Generated with Claude Code

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>
@wtoqxy0000 wtoqxy0000 requested review from a team as code owners January 18, 2026 15:51
@github-actions github-actions Bot added robotics Robotics code changes python Python code labels Jan 18, 2026
openminddev and others added 2 commits January 18, 2026 15:47
Removed redundant comments and improved docstrings for several methods in WebSim.py. Cleaned up initialization and server startup code for better readability and maintainability.
@openminddev openminddev merged commit 926050e into OpenMind:main Jan 18, 2026
5 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code robotics Robotics code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]WebSim Event Loop Conflict

2 participants