python - Does a daemon thread run in the background? -


i confused daemon , non daemon thread in python. read non daemon thread exits when main thread exit in python!

but here read in java daemon thread runs in background!

i have read many different discussions on stackoverflow daemon , non daemon threads, still confused!

can please clarify thread able run in background using python?

try this:

import threading help(threading.thread) 

then scroll down documentation of data descriptors, in particular "daemon" flag. there, find info:

daemon    boolean value indicating whether thread daemon thread.     must set before start() called, otherwise runtimeerror    raised. initial value inherited creating thread;    main thread not daemon thread , therefore threads created in    main thread default daemon = false.     entire python program exits when no alive non-daemon threads    left. 

in particular last sentence important, because questions implicitly answered that. note contradicts first claim "non daemon thread exits when main thread exit". also, other languages behave differently, example reference java may true, useless explain python behaviour. checking documentation, seems java uses term "daemon thread" python does.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -