Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclosed event loop with easing example #127

Closed
sanders41 opened this issue Oct 1, 2021 · 13 comments
Closed

Unclosed event loop with easing example #127

sanders41 opened this issue Oct 1, 2021 · 13 comments
Labels
bug Something isn't working

Comments

@sanders41
Copy link
Contributor

Every time I close the easing example. I get the following error:

/usr/lib/python3.9/asyncio/base_events.py:681: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback

I am thinking there are still messages processing at shutdown that are keeping the loop running, but I have not been able to track down the root cause yet.

Possibly a similar issue to #82?

OS: Manjaro Linux 21.1.4

@willmcgugan
Copy link
Collaborator

Interesting. I don't see that, probably because I develop with 3.7. Shutting down cleanly is one of the hardest things about asyncio.

@willmcgugan willmcgugan added the bug Something isn't working label Oct 1, 2021
@sanders41
Copy link
Contributor Author

I tested 3.7 and am seeing the error there also. I tried it out on my Mac, and there it seems to be random. Sometimes I get the error and sometimes I don't with 3.7, 3.8, and 3.9.

@willmcgugan
Copy link
Collaborator

Are you certain you are running the latest code? What does pip freeze | grep textual give you?

It has very possibly reoccured, but I had fixed a very similar issue a while back.

@sanders41
Copy link
Contributor Author

I'm running from my fork. I tried pull upstream and then a fresh poetry install, but am still seeing the error. Do I need to do a separate install to run the examples?

@willmcgugan
Copy link
Collaborator

Try uninstalling textual first, but I would have thought that would be enough.

So you are seeing this on Linux consistently, but MacOS intermittently?

@sanders41
Copy link
Contributor Author

I tried deleting poetry's virtual environment and re-creating it, but no difference.

Correct, I am getting the error every time on Linux, but only intermittently on MacOS. I'll keep doing some testing to see if I can get any more information.

@lllama
Copy link
Contributor

lllama commented Oct 1, 2021

Not that I know what I'm talking about but there was a good talk at EuroPython a few years ago that talked about asyncio things, including shutting down gracefully.

@pom11
Copy link

pom11 commented Jan 7, 2022

Screenshot 2022-01-07 at 21 39 49

i get the same error when trying to get docker container status. along the dumped data i can see the widgets rendered.

  • textual 0.1.13
  • docker 5.0.3
  • python 3.8.10
class Container(Widget):

	mouse_over = Reactive(False)

	def __init__(self, id: str = None):
		super().__init__(id=id)
		self.id = id

	def container(self):
		try:
			client = docker.from_env()
			container = client.containers.get(self.id)
			status = container.status()
                        client.close()
			return status
		except Exception as e:
			return "Error"

	def on_mount(self):
		self.set_interval(1, self.refresh)

	def render(self):
		data = self.container()
		return Panel(data, style=("on red" if self.mouse_over else ""))

@olivierphi
Copy link

I can indeed reproduce the bug (on Ubuntu).

  • Python 3.8.13: the asyncio/base_events.py:686: ResourceWarning: unclosed event loop error is displayed in the background of the Textual display, when the easing example is launched - ⚠️ however it doesn't happen when uvloop is installed.
    Screenshot from 2022-05-04 10-55-21

  • Python 3.9.12: it is displayed when we exit the app with Ctrl+C - ⚠️ however it doesn't happen when uvloop is installed.

I'm going to take a look at this! 🙂

@olivierphi olivierphi self-assigned this May 4, 2022
@darrenburns
Copy link
Member

@drbenton There is an open PR above for this ^ Although I thought this wasn't an issue on the css branch

@olivierphi
Copy link

Status update: the bug seems to be fixed on the css branch, where the current Textual development is taking place. So hopefully it will no longer be visible when this branch will be merged to main 🙂 🤞

@olivierphi olivierphi removed their assignment May 11, 2022
@willmcgugan
Copy link
Collaborator

@github-actions
Copy link

Did we solve your problem?

Consider buying the Textualize developers a coffee to say thanks.

Textualize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants