[issue41128] Signal handlers should not hang during blocked main thread

Josef Havránek report at bugs.python.org
Fri Jun 26 13:34:49 EDT 2020


New submission from Josef Havránek <jhpepa at gmail.com>:

python3 When handling signals (via signal module) have delayed execution when main thread is blocked/waiting for event

That is sub-optimal(signal "could get lost"). Signals shoud be handled asap... Think about scenario when os may be asking python nicely before it sends os.kill...so we could be dead on next bytecode instruction of main thread.

In such scenario when main thread is blocked and VM recives signal it should "context switch" to handler immediately thus not being dependent on state of main thread to be in executable state.

This gotcha should be included in documentation of all 3.x version since there should be nothing running(including long-runing c computation like regex matching ;) ) and basicly nothing is preventing handler from execution 

more details and test script in file attached

ps excuse my english/typos and uglines of code... this is my 1st bug report/enhancment proposal

----------
components: Extension Modules
files: testscript.py
messages: 372435
nosy: Josef Havránek
priority: normal
severity: normal
status: open
title: Signal handlers should not hang during blocked main thread
type: enhancement
versions: Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49265/testscript.py

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


More information about the Python-bugs-list mailing list