Skip to content

FIX: start event loop thread when fit_predict_async called outside MCP server context#448

Open
echo-xiao wants to merge 1 commit intosktime:mainfrom
echo-xiao:fix/async-background-training
Open

FIX: start event loop thread when fit_predict_async called outside MCP server context#448
echo-xiao wants to merge 1 commit intosktime:mainfrom
echo-xiao:fix/async-background-training

Conversation

@echo-xiao
Copy link
Copy Markdown

Reference Issues/PRs

Fixes #446

What does this implement/fix? Explain your changes.

  • Fixed background async training job stuck at 0% progress when fit_predict_async_tool is called outside the MCP server context. The event loop exists but is not running, so scheduled coroutines never execute. Fix starts a background thread to run the event loop when it is not already running.

  • Fixed KeyError: 'data_source' in background_training_example.py by supporting both 'data_source' and 'dataset' keys for compatibility between PyPI and source versions.

Does your contribution introduce a new dependency? If yes, which one?

No. Uses only Python's built-in threading and asyncio modules.

What should a reviewer concentrate their feedback on?

  • The threading fix in fit_predict.py: whether starting a daemon thread is the correct approach when the event loop is not running
  • Whether this fix is safe to use within the MCP server context as well

Any other comments?

This bug was discovered while running the example scripts directly with python examples/background_training_example.py. The root cause is that fit_predict_async_tool uses run_coroutine_threadsafe(), which requires a running event loop. When called outside the MCP server, the loop exists but is not running, so coroutines are scheduled but never executed.

PR checklist

For all contributions
  • I've added unit tests and made sure they pass locally (make check).
  • I've added the tool to the online documentation in docs/source/.
  • I've updated the existing example scripts or provided a new one to showcase how my tool works in examples/.

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.

[BUG] background_training_example.py: async job stuck at 0% progress indefinitely

1 participant