MLServer icon indicating copy to clipboard operation
MLServer copied to clipboard

Fix Uvloop/Asyncio runtime error in worker.py

Open GrantDeljevic opened this issue 2 months ago • 2 comments

Below error occurred, the _ignore_signals() handler in worker.py ran into an error, I believe caused by a recent uvloop update when it tries to call asyncio.get_event_loop() where none exists/all loops are closed.

This PR skips _ignore_signals when there is no open loop.

Traceback (most recent call last):
  File "/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/python3.10/site-packages/mlserver/parallel/worker.py", line 70, in run
    self._ignore_signals()
  File "/python3.10/site-packages/mlserver/parallel/worker.py", line 81, in _ignore_signals
    loop = asyncio.get_event_loop()
  File "/python3.10/site-packages/uvloop/__init__.py", line 206, in get_event_loop
    raise RuntimeError(
RuntimeError: There is no current event loop in thread 'MainThread'.

GrantDeljevic avatar Oct 24 '25 13:10 GrantDeljevic

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 24 '25 13:10 CLAassistant

Hi @GrantDeljevic!

Thank you for the proposed fix, we are also aware of the issue. We're aiming to issue a patch release (1.7.2) containing the fix within the next week or so, but I want to fully support the new uvloop version rather than just applying the minimal work to stop the error.

Until then, we recommend users of custom-built MLServer images to pin uvloop to the previous version (0.21.0).

lc525 avatar Nov 05 '25 13:11 lc525