[issue41686] C++ Embedded 'time.sleep()' is not working on Windows host due to 'Py_InitializeEx(0)'

Eryk Sun report at bugs.python.org
Tue Sep 1 11:53:25 EDT 2020


Eryk Sun <eryksun at gmail.com> added the comment:

The SIGINT event gets created when the _signal extension module is imported. Until then, _PyOS_SigintEvent() returns NULL. But currently all code that calls _PyOS_SigintEvent() assumes it returns a valid handle. This has to be fixed to support Py_InitializeEx(0). 

For example, pysleep could call WinAPI Sleep on the main thread if the interrupt event isn't configured:

        ul_millis = (unsigned long)millisecs;
        hInterruptEvent = _PyOS_SigintEvent();

        if (ul_millis == 0 || !hInterruptEvent || !_PyOS_IsMainThread()) {
            Py_BEGIN_ALLOW_THREADS
            Sleep(ul_millis);
            Py_END_ALLOW_THREADS
            break;
        }

----------
components: +Windows
nosy: +eryksun, paul.moore, steve.dower, tim.golden, zach.ware
type:  -> behavior
versions: +Python 3.10, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41686>
_______________________________________


More information about the Python-bugs-list mailing list