These are chat archives for cherrypy/cherrypy

8th
Sep 2017
Ben Levine
@deevolution
Sep 08 2017 15:51
When creating a cherrypy server with an ephemeral port (i.e. cherrypy.config.update({'server.socket_port':0});cherrypy.engine.start() how can I find what port is picked?
Jason R. Coombs
@jaraco
Sep 08 2017 17:16
@deevolution This answer gets close - https://stackoverflow.com/a/20533675/70170
I’ve had to do this myself in the past two, but I don’t remember where.
Aha!
Looks like it’s cherrypy.server.bound_addr.
Ben Levine
@deevolution
Sep 08 2017 17:26
@jaraco Thanks. I saw that. Is there anyway to get the list of bound ports from the engine (i.e. can I get a list of the server objects it's hosting)?
Jason R. Coombs
@jaraco
Sep 08 2017 17:52
I’m not sure I follow.
I’m not aware of any way that CherryPy will bind to more than one port.
But maybe what you’re asking is for a list of connected socket objects to clients.
Ben Levine
@deevolution
Sep 08 2017 17:54
Actually cherrypy.server.bound_addr works perfectly.
Jason R. Coombs
@jaraco
Sep 08 2017 17:54
For that, I’m unsure if that’s exposed by the socket module itself or if it’s something that CherryPy would have to do. If the latter, I don’t recall CherryPy keeping a handle of such connections.
Aah. Excellent.
Ben Levine
@deevolution
Sep 08 2017 17:54
I overcomplicated this by bringing in the ServerAdapter.