Re: concurrent.futures vs gevent

2015-08-24 Thread jspicklemire
Some people have tried to make a case that concurrent.futures should be adopted 
as a replacement wherever greenlet based algorithms are in use. However, my 
experience is that greenelts combined with concurrent.futures provides 
significant advantages. In other words, to a degree the two approaches 
complement each other. 

Specifically, 'greening' a ThreadPoolExecutor delivers the simplicity of either 
a context manager, or a map, depending on the use case, hadling in a few lines 
of simple Python what might have otherwise been a complex call-back or 
'twisted' solution. 

Please note, this usage applies only to ThreadPool, not ProcessPool.

for example:

import eventlet
eventlet.patcher.monkey_patch(os=False, socket=True, select=True, thread=True)

futures = eventlet.import_patched('concurrent.futures') # 'greening' futures,
fut_tp_exec = futures.ThreadPoolExecutor

# the lines above enable even nested map / context manager 'futures'
# adding the lines below enables a vast number of 'simultaneous' HTTP requests.

import requests
req_f_sess = eventlet.import_patched('requests_futures.sessions') # 'green' req
o_rest_sess = req_f_sess.FuturesSession(executor=fut_tp_exec(max_workers=5000))
-- 
https://mail.python.org/mailman/listinfo/python-list


concurrent.futures vs gevent

2012-07-29 Thread subin
Hi,
It will be my first post here.
I just found a great presentation here
https://ep2012.europython.eu/conference/talks/concurrentfutures-is-here.

As non native english, i can't fully understand all of the material
presented there.
I have some doubt, i hope someone here can give clarification.

Could concurrent.futures be a (partly) replacement of gevent?
I guess not, because gevent provide lightweight thread via greenlet,
while concurrent.futures only provide multiprocessing across different
processor) (not lightweight).

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list