question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

asyncio event loop isn't closed on exit

See original GitHub issue

When run with Python 3.8.5 on Ubuntu 20.04 LTS, the event loop isn’t closed when the example is quit by pressing q.

Following error is output and the program exists:

/usr/lib/python3.8/asyncio/base_events:654: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>

The terminal is then printing raw bytes (?) of the mouse movement anytime you move the cursor over the window.

image

I’m not sure if it’s the Python version or some difference between Linux and OSX.

(In order to run the example I had to patch src/textual/_parser.py, because the type hint list[str] isn’t supported in 3.8. I just replaced it with list.)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
willmcgugancommented, Jun 17, 2021

Yeah, there is an entire shutdown procedure I need to figure out.

Not sure if you know this, but if your terminal gets messed up like this you can enter “reset” command.

1reaction
willmcgugancommented, Jul 23, 2021

That’s fixed in a branch I’m working on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Asyncio Event Loop is Closed" when getting loop
As of Python 3.7, the process of creating, managing, then closing the loop (as well as a few other resources) is handled for...
Read more >
Python 3.8+ raises "RuntimeError: Event Loop is closed" on ...
I assume this is yet another strange issue with asyncio's stream.close() - it schedules the closing of the socket but it's not guaranteed...
Read more >
Event Loop — Python 3.11.1 documentation
Close the event loop. The loop must not be running when this function is called. Any pending callbacks will be discarded. This method...
Read more >
Wait until a stream is closed? - Google Groups
A transport has a close() method but no wait_closed() method. In the UDP echo server example, tranport.close() is called while the event loop...
Read more >
RuntimeError: Event loop is closed : r/learnpython - Reddit
import requests, aiohttp, asyncio, re apple = [] link ... How can I fix this RuntimeError: Event loop is closed error? Thank you!!...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found