classification
Title: Signal handlers should not hang during blocked main thread
Type: behavior Stage:
Components: Extension Modules Versions: Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List:
Priority: normal Keywords:

Created on 2020-06-26 17:34 by Josef Havránek, last changed 2020-07-04 13:23 by Josef Havránek.

Files
File name Uploaded Description Edit
testscript.py Josef Havránek, 2020-06-26 17:34 script demonstating issue
Messages (1)
msg372435 - (view) Author: Josef Havránek (Josef Havránek) Date: 2020-06-26 17:34
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
History
Date User Action Args
2020-07-04 13:23:47Josef Havráneksetnosy: - Josef Havránek
2020-06-26 18:31:27Josef Havráneksettype: enhancement -> behavior
2020-06-26 17:34:49Josef Havránekcreate