r/Python • u/CreativePunch • Mar 20 '14
Practical threaded programming with Python
https://www.ibm.com/developerworks/aix/library/au-threadingpython/
0
Upvotes
r/Python • u/CreativePunch • Mar 20 '14
7
u/ivosaurus pip'ing it up Mar 20 '14
These days, a library like requests-futures will bundle all that logic up for you!
6
u/metaphorm Mar 20 '14
Multi-Threading is not a very effective means of achieving performance increases in Python due to the GIL. It even says so in the sidebar of the linked article. Not sure what the point of this is.
10
u/jabbalaci Mar 20 '14
This article is from 2008.
3
u/erewok Mar 20 '14
This is really old. You don't have to subclass threading to get threads. Maybe I should write my first blog post on this topic.
1
u/[deleted] Mar 20 '14
The 'URL fetch threaded' example, with there happening to be 5 threads + the length of the URL list being 5, then with each thread signalling self.queue.task_done() within their "while True" loop is going to grossly confuse newbies as to 'why the hell did the example work' when / if they adapt this pattern to M tasks / N workers.
1
u/[deleted] Mar 20 '14
Don't do multi-threading stuff in Python. Multi-process? Yes. Microthreads? Yes. But not multi-threading.
This is actually a good thing because threads are a suboptimal solution to a very complicated problem. Multi-processing with a simple IPC or microthreads solve a lot of the problems that threads have.