Re: exit ThreadPoolExecutor immediately

2016-11-15 Thread woooee
Doug Hellmann has what looks like a similar example using a poison pill (2nd example at) https://pymotw.com/2/multiprocessing/communication.html#multiprocessing-queues Note that join() allows the processes to finish so it you don't care then don't "join()" them. You can also terminate a multi

Re: exit ThreadPoolExecutor immediately

2016-11-15 Thread dieter
Atul Johri writes: > I am looking for a way to stop a ThreadPoolExecutor immediately under the > assumption that I don't care about what's currently running or pending. > > ``` > limit = 2 > executor = ThreadPoolExecutor(10) > posts = itertools.islice(mygen(executor=executor, **kwargs), 0, limit)

exit ThreadPoolExecutor immediately

2016-11-14 Thread Atul Johri
I am looking for a way to stop a ThreadPoolExecutor immediately under the assumption that I don't care about what's currently running or pending. ``` limit = 2 executor = ThreadPoolExecutor(10) posts = itertools.islice(mygen(executor=executor, **kwargs), 0, limit) for post in posts: print(post)