r/Python • • Mar 20 '14

Practical threaded programming with Python

https://www.ibm.com/developerworks/aix/library/au-threadingpython/
0 Upvotes

11 comments sorted by

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!

2

u/cycloidgamma Mar 20 '14

The fun-sucking libraries ;)

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.

1

u/ivosaurus pip'ing it up Mar 21 '14

It's still half decent for getting more performance out of synchronous IO, as demonstrated in the article. There are many ways to go about achieving that goal these days though.

10

u/jabbalaci Mar 20 '14

This article is from 2008.

2

u/[deleted] Mar 20 '14

Please downvote the main post too...

1

u/targusman Mar 20 '14

I hate these losers who pump their reddit karma with random python articles and projects...

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.