[ZCM] [ZC] 1527/ 1 Request "Clean Zope shutdown for Windows"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Tue Oct 12 00:41:48 EDT 2004


Issue #1527 Update (Request) "Clean Zope shutdown for Windows"
 Status Pending, Zope/feature+solution medium
To followup, visit:
  http://collector.zope.org/Zope/1527

==============================================================
= Request - Entry #1 by mhammond on Oct 12, 2004 12:41 am


Uploaded:  "Lifetime.patch"
 - http://collector.zope.org/Zope/1527/Lifetime.patch/view
On Windows, a 'select' call is not interrupted by a Ctrl+C.  Currently, pressing Ctrl+C requires you to wait up to 30 seconds (for the select to timeout) before anything happens.

When something does happen, Windows sees an unhandled Keyboard interrupt.  This is because no signal handlers are installed for Windows.  SIGINT does work on Windows, but fixing that still leaves us with the non-interruptable select().

Attached is a patch for Lifetime.py that solves this.  It will only be effective with pywin32/win32all builds 203 or later, but should gracefully and silently continue with the existing behaviour if these are not installed.  I will also be submitting a patch to WinBuilders so it grabs the binaries from the pywin32-203 installer.

The patch installs a windows "control handler".  Ctrl+C/Break etc are delivered asynchronously (notwithstanding the GIL) to a new thread.  This new thread triggers a shutdown, then tricks asyncore into breaking out of its 'select' call.  In the patch, the new function interrupt_select() may not be implemented correctly - see the comments in the function.

I note that on Linux a SIGINT does *not* trigger a normal shutdown (fast or otherwise).  I see no reason not to cleanly shutdown on Windows (and good ones for doing so), so the semantics are slightly different.  Pressing Ctrl+C once triggers a normal shutdown.  Pressing it again switches to "fast" shutdown.  A final Ctrl+C will terminate.  The first Ctrl+Break terminates.  A "Console Close" event does a fast shutdown.  All of this is obviously up for grabs.

All feedback welcome
==============================================================



More information about the Zope-Collector-Monitor mailing list