What’s the difference between the threading and thread modules in Python?
What’s the difference between the threading and thread modules in Python?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Python 3,
threadhas been renamed to_thread. It is infrastructure code that is used to implementthreading, and normal Python code shouldn’t be going anywhere near it._threadexposes a fairly raw view of the underlying OS level processes. This is almost never what you want, hence the rename in Py3k to indicate that it is really just an implementation detail.threadingadds some additional automatic accounting, as well as several convenience utilities, all of which makes it the preferred option for standard Python code.Note: as mentioned in Jeril’s alternate answer, when considering the use of threads in Python for execution of background tasks, also take a look at
concurrent.futures.ThreadPoolExecutoras an even higher level API thanthreading: https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor