New submission from Thomas Keppler:
Hi,
I have been playing around with threading.Timer objects as timeouts for a
project and noticed that my timeouts are affected by system time changes.
To test this, I have written a small demonstration script (timer_testcase.py)
which you can find in the attachments. I would expect that after 120 seconds, a
"Hello!" message will appear on the screen regardless of system time changes.
If you run the script like you would normally, you will see that it will work
properly and my expectations are met. Now, run it again and immediately use
"date +%T -s "HH:MM:SS"" where the time is >= 2 mins in the future. You will
notice that the timer will latch immediately instead of waiting those 120
seconds before latching.
I have read Lib/threading.py to a certain extent and it seems like Timer
objects are using monotonic time already because they use Events which use
Conditions themselves, which references a "_timer" function that is just an
alias for time.monotonic as one can see at the top of the file.
Then I checked out if the monotonic time works as expected (test_monotonic.py)
by just jumping back and forth "in time", everything seemed to be normal.
Am I making a mistake and if so, where?
Thanks for any of your answers.
--
Best regards
Thomas
Environment: I'm using Python 3.5.3 on Debian 9.1 "Stretch" on x86_64.
--
components: Library (Lib)
files: timer_testcase.py
messages: 300765
nosy: winfreak
priority: normal
severity: normal
status: open
title: threading.Timer object is affected by changes to system time
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file47096/timer_testcase.py
___
Python tracker
<http://bugs.python.org/issue31267>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com