[issue43821] Undocumented behavior of sleep functions and asyncio delayed execution

2021-04-12 Thread Josef Havránek

New submission from Josef Havránek :

Hi i found undocumented behavior of time.sleep, and call_at / call_later from 
asyncio loop


There are two things to properly document/consider.
It is time of delay/sleep when time for python stops  (aka computer is going to 
hibernate/Cpu not runing) because time is relative from view of RTC(real time 
clock) and program both is correct 

curent behavior on
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr  6 2021, 13:40:21) [MSC v.1928 64 bit 
(AMD64)] on win32

There is  time.sleep , asyncio.sleep and call_later 
They stall for time that has pased for program not on RTC (so it may take time) 
they not resume when time already passed in real word

then there is loop.call_at

there in in doc  two kinda contradicadictory statements.
and that is 
"This method’s behavior is the same as call_later()"

"and Schedule callback to be called at the given absolute timestamp when (an 
int or a float), using the same time reference as loop.time()."

thing is it should be legal acording to 1st qoute use
loop.call_at(seconds_to_sleep, lambda:print("something usefull")

but acording to 2nd we should use 
loop.call_at(seconds_to_sleep+loop.time(), lambda:print("something usefull")

and They Both execute after seconds_to_sleep! this is a bug because time to 
sleep cant be bigger than curent loop.time() then it would execute at incorect 
time.


Also there is second bug
loop.call_at(seconds_to_sleep+loop.time(), lambda:print("something usefull")

Even this is acording to me(how i understood from doc correct usage)
This will efectively behave as call_later because it will not call callback 
when seconds_to_sleep already passed since submission

however using
loop.call_at(seconds_to_sleep, lambda:print("something usefull")
will invoke as soon as program resumed from hybernation/when missed

i think loop.call_at(seconds_to_sleep, lambda:print("something usefull") should 
not wait seconds_to_sleep when it is smaller then loop.time() and just execute 
it

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 390914
nosy: Josef Havránek, docs@python
priority: normal
severity: normal
status: open
title: Undocumented behavior of sleep functions and asyncio delayed execution
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue43821>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2020-06-26 Thread Josef Havránek

New submission from Josef Havránek :

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 
<https://bugs.python.org/issue41128>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2020-06-26 Thread Josef Havránek

Change by Josef Havránek :


--
type: enhancement -> behavior

___
Python tracker 
<https://bugs.python.org/issue41128>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2020-07-04 Thread Josef Havránek

Change by Josef Havránek :


--
nosy:  -Josef Havránek

___
Python tracker 
<https://bugs.python.org/issue41128>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com