Problems with automatic reloading and wsgiref

257 views
Skip to first unread message

Peter Hoffmann

unread,
Jun 17, 2007, 6:28:11 AM6/17/07
to colubrid-users
Hi,

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

Armin Ronacher

unread,
Jun 17, 2007, 7:14:05 AM6/17/07
to colubri...@googlegroups.com
Hi,

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

Mike Vorozhbensky

unread,
Jun 18, 2007, 2:49:26 AM6/18/07
to colubri...@googlegroups.com
Hello.

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]

Peter Hoffmann

unread,
Jun 18, 2007, 11:41:03 AM6/18/07
to colubrid-users
> 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.


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

Mike Vorozhbensky

unread,
Jun 19, 2007, 3:28:19 AM6/19/07
to colubri...@googlegroups.com
2007/6/18, Peter Hoffmann <tos...@gmail.com>:

>
> 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?
>

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]

Peter Hoffmann

unread,
Jun 19, 2007, 7:00:33 PM6/19/07
to colubrid-users

On 19 Jun., 09:28, "Mike Vorozhbensky" <mike.vorozhben...@gmail.com>
wrote:

>
> 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/0...

>
> 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.

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

Reply all
Reply to author
Forward
0 new messages