-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
duplicate 🗐Seen it beforeSeen it beforesubmodule ⊂Periphery/subclassesPeriphery/subclassessynchronisation ⇶Multi-thread/processingMulti-thread/processingto-merge ↰ImminentImminent
Description
Python 2.7:
4.23.4 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] linux2
Python 3.6:
4.23.4 3.6.3 (default, Dec 4 2017, 11:26:35)
[GCC 4.8.4] linux
In Python 2.7 everything works as expected: interpreter exits when KeyboardInterrupt is received.
In Python 3.6 the monitor thread does not exit if KeyboardInterrupt is received before TMonitor.sleep_interval
has passed once.
In both cases TMonitor.was_killed
is never set, but in Python 3.6 the monitor requires a second KeyboardInterrupt to exit.
from __future__ import print_function, division, unicode_literals
import time
import random
import tqdm
p = tqdm.tqdm(range(1000))
try:
for i in p:
time.sleep(random.random() / 10)
finally:
print('was_killed:', tqdm.tqdm.monitor.was_killed.is_set())
# tqdm.tqdm.monitor.was_killed.set()
Uncomment the last line to "fix" the problem in 3.6.
Metadata
Metadata
Assignees
Labels
duplicate 🗐Seen it beforeSeen it beforesubmodule ⊂Periphery/subclassesPeriphery/subclassessynchronisation ⇶Multi-thread/processingMulti-thread/processingto-merge ↰ImminentImminent