autogen icon indicating copy to clipboard operation
autogen copied to clipboard

RuntimeError: Event loop is closed at end of execution in Magentic One Ubuntu 24

Open ghosert opened this issue 1 year ago • 6 comments

What happened?

I followed the doc to setup everything for Magentic One and run it with this sample:

╭─  gmk-ubuntu   ~/autogen/python/packages/autogen-magentic-one
╰─ python examples/example.py --logs_dir ./my_logs

it works well but in the end of the session, it reports this error:

No agent selected.
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x7c0f158d7f60>
Traceback (most recent call last):
  File "/usr/lib/python3.12/asyncio/base_subprocess.py", line 126, in __del__
    self.close()
  File "/usr/lib/python3.12/asyncio/base_subprocess.py", line 104, in close
    proto.pipe.close()
  File "/usr/lib/python3.12/asyncio/unix_events.py", line 767, in close
    self.write_eof()
  File "/usr/lib/python3.12/asyncio/unix_events.py", line 753, in write_eof
    self._loop.call_soon(self._call_connection_lost, None)
  File "/usr/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
    self._check_closed()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

What did you expect to happen?

No error should be reported like above

How can we reproduce it (as minimally and precisely as possible)?

as mentioned in the above.

AutoGen version

Latest in the main branch

Which package was this bug in

Magentic One

Model used

gpt-4

Python version

3.12

Operating system

Ubuntu 24

Any additional info you think would be helpful for fixing this bug

No response

ghosert avatar Nov 12 '24 23:11 ghosert

Hmm. Thanks for the report. @jackgerrits any idea? This looks like a runtime thing.

afourney avatar Nov 13 '24 08:11 afourney

Yes I have seen this error before and discussed it with @ekzhu , I believe it is Python version issue with 3.12, but not sure how to fix

husseinmozannar avatar Nov 14 '24 05:11 husseinmozannar

Doesn't repro for me using Python 3.12.5 on MacOS. So likely an Ubuntu/Linux thing

jackgerrits avatar Nov 15 '24 21:11 jackgerrits

The base worker agent has a dangling background task running when the program exits.

ekzhu avatar Nov 15 '24 21:11 ekzhu

fix for this?

dominicdev avatar Nov 25 '24 06:11 dominicdev

Not yet, but the rewrite of MagenticOne on AgentChat should resolve this. We expect this to be fully out in the next few weeks or sooner.

husseinmozannar avatar Nov 25 '24 06:11 husseinmozannar

Not yet, but the rewrite of MagenticOne on AgentChat should resolve this. We expect this to be fully out in the next few weeks or sooner.

The issue still exists in Python 3.12 + AutoGen 0.5.6.

illusions-LYY avatar May 07 '25 11:05 illusions-LYY