when I use the execute(app, reload=True) feature with wsgiref
(0.1.2)/python2.4 or with python2.5 on debian etch I get the
following Error:
$ python testrun.py
Traceback (most recent call last):
File "testrun.py", line 11, in ?
execute(app, reload=True)
File "/home/ph/Desktop/wsgitest/test/colubrid/server.py", line 71,
in execute
run = make_server(hostname, port, app).serve_forever
File "/home/ph/Desktop/wsgitest/test/wsgiref/simple_server.py", line
181, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python2.4/SocketServer.py", line 330, in __init__
self.server_bind()
File "/home/ph/Desktop/wsgitest/test/wsgiref/simple_server.py", line
50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python2.4/BaseHTTPServer.py", line 101, in
server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.4/SocketServer.py", line 341, in server_bind
self.socket.bind(self.server_address)
File "<string>", line 1, in bind
socket.error: (98, 'Address already in use')
There is no other application running on the address/port and the test
app runs fine with reload=False.
When I use paste instead of wsgiref it works without problems, too.
Any hints?
Regards Peter
Peter Hoffmann wrote:
> There is no other application running on the address/port and the test
> app runs fine with reload=False.
>
> When I use paste instead of wsgiref it works without problems, too.
> Any hints?
That's an issue that appears from time to time for various people but we
never found out why that's the case. :(
Regards,
Armin
I know this problem, it's not a Colubrid problem.
Then linux closing client connection, connection not closed
immediately, realy it set to state "TIME_WAIT", and will be closed
after small waiting.
You can't close server socket, and bind it again if any client
connection in TIME_WAIT state.
--
[by Fox]
But this should not be a problem here because wsgiref.WSGIServer is
a subclass of the normal BaseHttpServer.HTTPServer. And the HTTPServer
defines allow_reuse_address = 1 which leads in SocketServer.TCPServer
to the following code:
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
So reusing the socket in TIME_WAIT state should be possible, or am I
missing something?
Regards Peter
I found some intersting links about SO_REUSEADDR
problem information:
http://cygwin.com/ml/cygwin/2004-10/msg00250.html
possible solution:
http://lists.freebsd.org/pipermail/freebsd-emulation/2003-September/000168.html
SO_REUSEADDR worked perfectly in windows systems, but in linux it not work,
try to change SO_REUSEADDR to SO_REUSEPORT to resolve this problem.
--
[by Fox]
Unfortunately this does not work on my linux box because SO_REUSEPORT
ist not available.
Thanks anyway for your input. When I've got a little more spare time
I'll try to figure out how the paste server solves the problem.
Until then I will use paste for development and debugging.
Regards Peter