Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I realize this is useful for cpu-bound computations; but for network-bound here is a REAL two-liner that will instantly make your program concurrent (not parallel):

    from gevent import monkey
    monkey.patch_all()
This is a lot lighter than processes. You can combine the two- use gevent to handle network, and then multiprocessing to handle cpu stuff!


There's even a gevented version of requests called grequests.

The only thing about gevent is that the docs kind of suck, but their apis are pretty intuitive and the code itself is well documented.


I've heard that using gevent with multiprocessing can cause problems, is that still the case?


I've used gevent in multiprocess situations, and it worked just fine. I did rig up my own gevent-based IPC, though. Just create a socketpair before forking, and attach some JSON-RPC (or protobuf/msgpack/etc) endpoints after.


You don't want multiprocessing to fork your process after gevent is loaded. If you can avoid that (like hold off on monkey patching) then it works great.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: