Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3ca4d52

Browse files
Create threading_daemon_join.py
1 parent 1b4660b commit 3ca4d52

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎scripts/threading_daemon_join.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
import threading
3+
import time
4+
import logging
5+
6+
7+
def daemon():
8+
logging.debug('Starting')
9+
time.sleep(0.2)
10+
logging.debug('Exiting')
11+
12+
13+
def non_daemon():
14+
logging.debug('Starting')
15+
logging.debug('Exiting')
16+
17+
18+
logging.basicConfig(
19+
level=logging.DEBUG,
20+
format='(%(threadName)-10s) %(message)s',
21+
)
22+
23+
d = threading.Thread(name='daemon', target=daemon, daemon=True)
24+
25+
t = threading.Thread(name='non-daemon', target=non_daemon)
26+
27+
d.start()
28+
t.start()
29+
30+
d.join()
31+
t.join()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /