Pylons / waitress

Waitress - A WSGI server for Python 3
https://docs.pylonsproject.org/projects/waitress/en/latest/
Other
1.45k stars 176 forks source link

waitress crash while launching flask server #333

Closed Taysssir closed 3 years ago

Taysssir commented 3 years ago

We have a simple Flask app : waitress version : 1.4.4

Serving flask app : 
serve(app, host = HOST ,port = PORT)

Startup works correctly(75%) but sometimes it crashes (25%) while launching server.

Any tips or help would be greatly appreciated!

Traceback (most recent call last):

  File "/usr/local/lib/rest_server/rest_server.py", line 15, in <module>
    serve(app, host=HOST,port=PORT)
  File "/usr/local/lib/python2.7/site-packages/waitress/__init__.py", line 12, in serve
    server = _server(app, **kw)
  File "/usr/local/lib/python2.7/site-packages/waitress/server.py", line 88, in create_server
    sockinfo=sockinfo)
  File "/usr/local/lib/python2.7/site-packages/waitress/server.py", 239, in __init__
    self.bind_server_socket()
  File "/usr/local/lib/python2.7/site-packages/waitress/server.py", 368, in bind_server_socket
    self.bind(sockaddr)
  File "/usr/local/lib/python2.7/site-packages/waitress/wasyncore.py", 398, in bind
    return self.socket.bind(addr)
stevepiercy commented 3 years ago

More information is needed to help you.

A complete text traceback would be more helpful than an image of one.

Please include the version of Waitress you have installed. 1.4.4 is the latest stable version, and a 2.0 beta is available.

What command do you use to start your app? Can you provide sample code to reproduce the issue?

Taysssir commented 3 years ago

@stevepiercy Thanks for your replying,

Traceback (most recent call last):

  File "/usr/local/lib/rest_server/rest_server.py", line 15, in <module>
    serve(app, host=HOST,port=PORT)
  File "/usr/local/lib/python2.7/site-packages/waitress/__init__.py", line 12, in serve
    server = _server(app, **kw)
  File "/usr/local/lib/python2.7/site-packages/waitress/server.py", line 88, in create_server
    sockinfo=sockinfo)
  File "/usr/local/lib/python2.7/site-packages/waitress/server.py", 239, in __init__
    self.bind_server_socket()
  File "/usr/local/lib/python2.7/site-packages/waitress/server.py", 368, in bind_server_socket
    self.bind(sockaddr)
  File "/usr/local/lib/python2.7/site-packages/waitress/wasyncore.py", 398, in bind
    return self.socket.bind(addr)

Actually i am using the stable version which is "waitress-1.4.4". Launch the flask server :

$python rest_server.py The problem does not persist for the first or the second time .. For example if I run my server 10 times, I will have 1 in 10 crashes and 9 are launched correctly .. I would like to know, where the problem persists, from the package itself, port is busy .. any information you are going to offer me is useful for me ... Otherwise how can I correct it?

stevepiercy commented 3 years ago

What is in your rest_server.py?

What is your operating system and version?

When you say, "I run my server 10 times", do you stop it between runs? If so, how do you stop it? Perhaps the bind to the addr has not been released? That's just a guess, I really don't know.

We need to be able to reproduce the issue to help you. The traceback does not provide enough information.

I notice that your are using Python 2.7. If this is a new application, I would strongly recommend that you use Python 3.6 or greater. See https://devguide.python.org/#status-of-python-branches

Taysssir commented 3 years ago

I am using ubuntu 18.04 OS ..I used keyboard inturupt ctr + c to stop the server between runs

digitalresistor commented 3 years ago

It sounds like the OS os still holding on to the socket for some reason or another after the Ctrl + C.

You can check the state of a socket by using netstat.

you have hidden a part of the error message that would actually tell us what is going on, the traceback tells us the error occurred in bind, but not what error occurred. Could you please provide that information, since it should contain an error number as well as an error reason.

digitalresistor commented 3 years ago

I am closing this until we get more information, including the full traceback and the errno presented.