This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vScherba
Recipients vScherba
Date 2014-02-04.19:03:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
To get the bug:
1. Windows Server 2003 (same bug should be under earlier versions: XP, 2000, ...).
2. Any Windows service should spawn process with Python script.
3. Py script should stay into time.sleep.
4. Any Windows user should login in console session 0.
5. Bug: when this user logoff, script interrupts.

To repeat the bug simply you could use srvany which spawn: python.exe -c "import time; time.sleep(10000)".

There is problem in cpython/Modules/timemodule.c in PyCtrlHandler.
Before logoff Windows broadcasts to all services and its children CTRL_LOGOFF_EVENT signal. But PyCtrlHandler doesn't filter it out by dwCtrlType and always sets hInterruptEvent. This forces script interruption.

CTRL_SHUTDOWN_EVENT also should be filtered out. CTRL_SHUTDOWN_EVENT broacasted to all services before Windows shutdown. But after it has been handled, other process can block or pause shutdowning.

Default Windows console control handler does not call ExitProcess when processing the CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT signals. See more at

On Win Vista and higher bug not presents. Impossible to login to session 0 because of session 0 isolation.

Patch attached. There is same fix in cpython/Modules/_multiprocessing/multiprocessing.c
Date User Action Args
2014-02-04 19:03:28vScherbasetrecipients: + vScherba
2014-02-04 19:03:28vScherbasetmessageid: <>
2014-02-04 19:03:28vScherbalinkissue20513 messages
2014-02-04 19:03:28vScherbacreate