DEV Community

Discussion on: How to make Python code concurrent with 3 lines

Collapse
 
rrampage profile image
Raunak Ramakrishnan

Great article. I was not aware of concurrent.futures in standard library.

I use gevent in Python 2 for light-weight threads. It uses green threads under the hood. The API is very simple to use. If you have a lot of IO bound tasks, e.g downloading over 100 files / making a lot of requests concurrently, this library is very useful.

Collapse
 
rhymes profile image
rhymes

Great article. I was not aware of concurrent.futures in standard library.

I don't think you're the first one, the various "what's new in Python" contain a lot of gems over the years ;)

I use gevent in Python 2 for light-weight threads. It uses green threads under the hood. The API is very simple to use. If you have a lot of IO bound tasks, e.g downloading over 100 files / making a lot of requests concurrently, this library is very useful.

Yeah gevent is nice though I've never been a huge fan of cooperative multi tasking as a concurrency paradigm. It's true as you say that for I/O bound tasks has it uses though.

The objective of the post was to uncover a hidden gem in the standard library. Regarding async I/O you might want to take a look at asyncio in the standard library (Python 3's) and uvloop outside the library!

Collapse
 
rrampage profile image
Raunak Ramakrishnan

uvloop is excellent! I have used it for Python 3 based web-services.

Thread Thread
 
rhymes profile image
rhymes

Nice! You should make a post about it!

:-)

Thread Thread
 
rrampage profile image
Raunak Ramakrishnan

All in due time :)

Collapse
 
sandordargo profile image
Sandor Dargo

I agree, have a look at asyncio, that seems to be the future. Better to say it's already the present!