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

Determine source of ResourceWarning #59

Closed
briancohan opened this issue Jul 14, 2021 · 4 comments · Fixed by #61
Closed

Determine source of ResourceWarning #59

briancohan opened this issue Jul 14, 2021 · 4 comments · Fixed by #61
Projects

Comments

@briancohan
Copy link
Contributor

Every time I run the app, this error is left in my terminal

/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
@briancohan briancohan added this to Backlog in Code Jam via automation Jul 14, 2021
@mustafaquraish
Copy link
Contributor

That's because StackOverflowFinder created a requests session but never closes it. This can probably be fixed by not creating the session in __init__() anymore. I believe now we just compute the results once upfront anyway, so we can just create the session object in search() at the start, and then close it at the end of the function. This should get rid of the error

@briancohan
Copy link
Contributor Author

That's because StackOverflowFinder created a requests session but never closes it. This can probably be fixed by not creating the session in __init__() anymore. I believe now we just compute the results once upfront anyway, so we can just create the session object in search() at the start, and then close it at the end of the function. This should get rid of the error

I don't see the error when I use the -n flag. That implies that it's coming from textual not StackOverflowFinder

mustafaquraish added a commit that referenced this issue Jul 14, 2021
This issue was caused by a session that was not being closed. We
now only create the session when needed and close it immediately
after we are done with it.
@mustafaquraish
Copy link
Contributor

I don't see the error when I use the -n flag. That implies that it's coming from textual not StackOverflowFinder

This is because when we run with -n the python program exits gracefully and everything is closed. Textual behaves a bit weirdly because it's being run through asyncio which takes over the control loop I believe, and something weird is happening. Look at the PR I made, that should fix the issue.

Code Jam automation moved this from Backlog to Complete Jul 14, 2021
briancohan added a commit that referenced this issue Jul 14, 2021
@mustafaquraish
Copy link
Contributor

It seems that the issue had been fixed for a while when I made the fix, but for some reason I am getting the same error message again. I guess it might actually have something to do with textual. Weird.

Code Jam automation moved this from Complete to In Progress Jul 15, 2021
Code Jam automation moved this from In Progress to Complete Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Code Jam
Complete
Development

Successfully merging a pull request may close this issue.

2 participants