[CherryPy] #645: A value of 0 for socket_port should cause CP to bind to an avaibale unused port

0 views
Skip to first unread message

CherryPy

unread,
Jan 16, 2007, 12:56:31 PM1/16/07
to cherrypy...@googlegroups.com
#645: A value of 0 for socket_port should cause CP to bind to an avaibale unused
port
---------------------------------+------------------------------------------
Reporter: drag...@gmail.com | Owner: rdelon
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Keywords:
---------------------------------+------------------------------------------
When socket_port is specified as 0, an exception is thrown as follows:

{{{
File
"/localhome/raghu/localwork/cherrypy/svn.cherrypy.org/trunk/cherrypy/_cpserver.py",
line 69, in quickstart
self.start()
File
"/localhome/raghu/localwork/cherrypy/svn.cherrypy.org/trunk/cherrypy/_cpserver.py",
line 95, in start
self._start_http(httpserver)
File
"/localhome/raghu/localwork/cherrypy/svn.cherrypy.org/trunk/cherrypy/_cpserver.py",
line 118, in _start_http
self.wait(httpserver)
File
"/localhome/raghu/localwork/cherrypy/svn.cherrypy.org/trunk/cherrypy/_cpserver.py",
line 159, in wait
wait_for_occupied_port(*bind_addr)
File
"/localhome/raghu/localwork/cherrypy/svn.cherrypy.org/trunk/cherrypy/_cpserver.py",
line 247, in wait_for_occupied_port
raise IOError(msg)
IOError: Port 0 not bound on 'localhost'
}}}

I am using the latest code from the trunk. It appears to me that even
though wsgiserver is properly passing 0 to socket.bind (and hence binding
to an unused port), other parts of the code still use "configured" port
which is 0.

--
Ticket URL: <http://www.cherrypy.org/ticket/645>
CherryPy <http://www.cherrypy.org>
CherryPy - a pythonic, object-oriented HTTP framework

CherryPy

unread,
Jan 25, 2007, 3:28:06 PM1/25/07
to cherrypy...@googlegroups.com
#645: A value of 0 for socket_port should cause CP to bind to an avaibale unused
port
---------------------------------+------------------------------------------
Reporter: drag...@gmail.com | Owner: rdelon
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Comment (by drag...@gmail.com):

I am attaching a small patch that seems to work with port 0. My only
intention in uploading the patch is to suggest it as a starting point. It
will take more time for me to understand all its implications and suggest
a more thorough solution.

The web server will update its bind_addr after doing socket.bind() so that
correct port can be obtained. This port will obviously be different from
the original port if the original port was 0. Unfortunately, the code that
started the web server needs to wait for this setting before proceeding
further. Right now, I just added time.sleep(5) as I don't know of a better
solution.

CherryPy

unread,
Jan 26, 2007, 1:12:43 AM1/26/07
to cherrypy...@googlegroups.com
#645: A value of 0 for socket_port should cause CP to bind to an avaibale unused
port
---------------------------------+------------------------------------------
Reporter: drag...@gmail.com | Owner: fumanchu
Type: enhancement | Status: assigned
Priority: normal | Milestone: 3.0
Component: CherryPy code | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Changes (by fumanchu):

* milestone: => 3.0
* owner: rdelon => fumanchu
* status: new => assigned

Comment:

That's a good start, but there's no API guarantee that a given httpserver
will possess a "bind_addr" attribute. So we'd either need to add that to
the API (which is fine, just needs to be decided) or use some other method
of passing that information back up to the Server object.

If we ''did'' add a "bind_addr" requirement, that would mean we could stop
using a dict for httpservers and use a list instead (and consumers could
inspect [server.bind_addr for server in httpservers] if they cared). That
might be the way to go.

CherryPy

unread,
Oct 26, 2007, 3:13:58 AM10/26/07
to cherrypy...@googlegroups.com
#645: A value of 0 for socket_port should cause CP to bind to an avaibale unused
port
---------------------------------+------------------------------------------
Reporter: drag...@gmail.com | Owner: fumanchu
Type: enhancement | Status: assigned
Priority: normal | Milestone: 3.2
Component: CherryPy code | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Changes (by fumanchu):

* milestone: 3.0 => 3.2

CherryPy

unread,
Jul 4, 2009, 1:38:49 PM7/4/09
to cherrypy...@googlegroups.com
#645: A value of 0 for socket_port should cause CP to bind to an avaibale unused
port
---------------------------------+------------------------------------------
Reporter: drag...@gmail.com | Owner: fumanchu
Type: enhancement | Status: assigned
Priority: normal | Milestone:
Component: wsgiserver | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Changes (by fumanchu):

* milestone: 3.2 =>
Reply all
Reply to author
Forward
0 new messages