plone / plone.recipe.zope2instance

zc.buildout recipe to setup and configure a Zope 2 instance.
https://pypi.org/project/plone.recipe.zope2instance
6 stars 23 forks source link

fast-listen: port still bound after foreground task stopped with Ctrl-C #86

Closed jensens closed 5 years ago

jensens commented 5 years ago

If run WSGI ./bin/instance fg with http-fast-listen = on on and stop the instance using Ctrl-C, the port ist still bound for a couple of seconds (~10-20). If started before that delay, the instance wont start again with:

Traceback (most recent call last):
  File "/home/jensens/workspace/pro/akifair/parts/instance/bin/interpreter", line 295, in <module>
    exec(compile(__file__f.read(), __file__, "exec"))
  File "/home/jensens/.buildout/shared-eggs/Zope-4.0b10-py2.7.egg/Zope2/Startup/serve.py", line 219, in <module>
    sys.exit(main() or 0)
  File "/home/jensens/.buildout/shared-eggs/Zope-4.0b10-py2.7.egg/Zope2/Startup/serve.py", line 216, in main
    return command.run()
  File "/home/jensens/.buildout/shared-eggs/Zope-4.0b10-py2.7.egg/Zope2/Startup/serve.py", line 178, in run
    relative_to=base, global_conf=vars)
  File "/home/jensens/.buildout/shared-eggs/Zope-4.0b10-py2.7.egg/Zope2/Startup/serve.py", line 211, in loadserver
    server_spec, name=name, relative_to=relative_to, **kw)
  File "/home/jensens/.buildout/shared-eggs/PasteDeploy-2.0.1-py2.7.egg/paste/deploy/loadwsgi.py", line 261, in loadserver
    return loadobj(SERVER, uri, name=name, **kw)
  File "/home/jensens/.buildout/shared-eggs/PasteDeploy-2.0.1-py2.7.egg/paste/deploy/loadwsgi.py", line 278, in loadobj
    return context.create()
  File "/home/jensens/.buildout/shared-eggs/PasteDeploy-2.0.1-py2.7.egg/paste/deploy/loadwsgi.py", line 715, in create
    return self.object_type.invoke(self)
  File "/home/jensens/.buildout/shared-eggs/PasteDeploy-2.0.1-py2.7.egg/paste/deploy/loadwsgi.py", line 189, in invoke
    context.global_conf, **context.local_conf)
  File "/home/jensens/.buildout/shared-eggs/PasteDeploy-2.0.1-py2.7.egg/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/home/jensens/.buildout/shared-eggs/plone.recipe.zope2instance-6.1.4-py2.7.egg/plone/recipe/zope2instance/ctl.py", line 908, in server_factory
    prebound.bind((host, int(port)))
  File "/home/jensens/.buildout/shared-eggs/waitress-1.2.1-py2.7.egg/waitress/wasyncore.py", line 369, in bind
    return self.socket.bind(addr)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
zopyx commented 5 years ago

Confirmed with Zope 4/Python 3

dataflake commented 5 years ago

This should probably be filed at https://github.com/Pylons/waitress/issues for waitress itself. Maybe move socket cleanup into at atexit hook.

dataflake commented 5 years ago

P.S.: Bjoern has a similar issue and they have an unmerged PR: https://github.com/jonashaag/bjoern/pull/155