We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f0a72f commit d057367Copy full SHA for d057367
cookbook/c12/p01_start_stop_thread.py
@@ -1,5 +1,6 @@
1
-
+import socket
2
import time
3
+
4
def countdown(n):
5
while n > 0:
6
print('T-minus', n)
@@ -12,10 +13,7 @@ def countdown(n):
12
13
t.start()
14
15
-if t.is_alive():
16
- print('Still running')
17
-else:
18
- print('Completed')
+print('Still running' if t.is_alive() else 'Completed')
19
20
21
t.join()
@@ -82,4 +80,4 @@ def run(self):
82
80
import multiprocessing
83
81
c = CountdownTask(5)
84
p = multiprocessing.Process(target=c.run)
85
-p.start()
+p.start()
0 commit comments