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

Stopping server instance produces "unclosed file" warning #264

Open
everdimension opened this issue Oct 15, 2019 · 6 comments
Open

Stopping server instance produces "unclosed file" warning #264

everdimension opened this issue Oct 15, 2019 · 6 comments

Comments

@everdimension
Copy link

everdimension commented Oct 15, 2019

Hi! Thanks you for making this library.

I have code like this in my main.py file:

from waitress import serve

# ...

serve(app, host='0.0.0.0', port=8080)

I run file from the terminal like this:

> python main.py
Serving on http://0.0.0.0:8080

Everything works fine. Then I want to shutdown the server. I press command + c

I see this warning:

^C/usr/local/lib/python2.7/site-packages/waitress/wasyncore.py:617: UserWarning: unclosed file <waitress.wasyncore.file_wrapper instance at 0x1054ab950>
  warnings.warn("unclosed file %r" % self, compat.ResourceWarning)

I'm not sure if this is intended. "Unclosed file" doesn't sound that good. Am I doing something wrong when I stop the server or is this intended behavior?

Thank you.

@stevepiercy
Copy link
Member

Please see the section "General Support" at https://pylonsproject.org/community-support.html

@mmerickel
Copy link
Member

You're on a roll @stevepiercy but I think this one counts more in the issue category than in the question category despite their nicely assuming it's user error.

@everdimension Does it shutdown immediately or after a few seconds? In general I don't usually see resource warnings when killing the server but they are notoriously difficult to reproduce/track down.

@everdimension
Copy link
Author

everdimension commented Oct 16, 2019

Does it shutdown immediately or after a few seconds?

Hm, I think I caught it once not stopping immediately (could not restart the server). But I cannot reproduce it.

But I see the unclosed file almost every time I interrupt the server with cmn + c.

@nkamkheaw
Copy link

nkamkheaw commented Apr 16, 2020

This happens to me 100% as well. It shutdowns right away. I'm running in a Raspberry Pi, FYI. I've been looking for a cleanup method where I can call in the signal handler, but I don't see one in init.py or anywhere.

@digitalresistor
Copy link
Member

waitress doesn't have any signal handlers defined and there are no cleanup methods or anything along those lines either, instead it relies on normal interrupts happening to the loop that is running, and which point it waits a little bit (unless there is no request being handled) before shutting the app down.

The file it's warning about is an os.pipe(), this is completely harmless. Until new shutdown handling is added to actually properly clean up the asyncore loop, this may continue to happen. I say may, because I haven't seen this error myself.

@Taysssir
Copy link

Taysssir commented Feb 5, 2021

@everdimension, i face the same problem, did you find a solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants