concurrency

concurrent.futures.ProcessPoolExecutor vs multiprocessing.pool.Pool

concurrent.futures.ProcessPoolExecutor vs multiprocessing.pool.Pool Question: Please explain to me what is the difference between these two classes? concurrent.futures.ProcessPoolExecutor multiprocessing.pool.Pool I noticed multiprocessing module existed in Python 2. But functionally? Asked By: ArekBulski || Source Answers: As stated in the documentation, concurrent.futures.ProcessPoolExecutor is a wrapper around a multiprocessing.Pool. As such, the same limitations of multiprocessing apply (e.g. …

Total answers: 1

Celery difference between concurrency, workers and autoscaling

Celery difference between concurrency, workers and autoscaling Question: In my /etc/defaults/celeryd config file, I’ve set: CELERYD_NODES=”agent1 agent2 agent3 agent4 agent5 agent6 agent7 agent8″ CELERYD_OPTS=”–autoscale=10,3 –concurrency=5″ I understand that the daemon spawns 8 celery workers, but I’m fully not sure what autoscale and concurrency do together. I thought that concurrency was a way to specify the …

Total answers: 2

How to properly create and run concurrent tasks using python's asyncio module?

How to properly create and run concurrent tasks using python's asyncio module? Question: I am trying to properly understand and implement two concurrently running Task objects using Python 3’s relatively new asyncio module. In a nutshell, asyncio seems designed to handle asynchronous processes and concurrent Task execution over an event loop. It promotes the use …

Total answers: 3

Yield from coroutine vs yield from task

Yield from coroutine vs yield from task Question: Guido van Rossum, in his speech in 2014 on Tulip/Asyncio shows the slide: Tasks vs coroutines Compare: res = yield from some_coroutine(…) res = yield from Task(some_coroutine(…)) Task can make progress without waiting for it As log as you wait for something else i.e. yield from And …

Total answers: 3

Python: Wait on all of `concurrent.futures.ThreadPoolExecutor`'s futures

Python: Wait on all of `concurrent.futures.ThreadPoolExecutor`'s futures Question: I’ve given concurrent.futures.ThreadPoolExecutor a bunch of tasks, and I want to wait until they’re all completed before proceeding with the flow. How can I do that, without having to save all the futures and call wait on them? (I want an action on the executor.) Asked By: …

Total answers: 3

What's the difference betwee "Actor model" and "Reactor pattern" in Python?

What's the difference betwee "Actor model" and "Reactor pattern" in Python? Question: https://en.wikipedia.org/wiki/Actor_model, the project is called “pulsar“ https://en.wikipedia.org/wiki/Reactor_pattern, the projects are Twisted and Tornado What’s the difference in the theory and practice? Asked By: est || Source Answers: There’s no difference. “Actor model” is somewhat more ambiguous, but both terms are sufficiently general that …

Total answers: 3

Executing multiple functions simultaneously

Executing multiple functions simultaneously Question: I’m trying to run two functions simultaneously in Python. I have tried the below code which uses multiprocessing but when I execute the code, the second function starts only after the first is done. from multiprocessing import Process def func1: #does something def func2: #does something if __name__==’__main__’: p1 = …

Total answers: 6

ProcessPoolExecutor from concurrent.futures way slower than multiprocessing.Pool

ProcessPoolExecutor from concurrent.futures way slower than multiprocessing.Pool Question: I was experimenting with the new shiny concurrent.futures module introduced in Python 3.2, and I’ve noticed that, almost with identical code, using the Pool from concurrent.futures is way slower than using multiprocessing.Pool. This is the version using multiprocessing: def hard_work(n): # Real hard work here pass if …

Total answers: 1

Greenlet Vs. Threads

Greenlet Vs. Threads Question: I am new to gevents and greenlets. I found some good documentation on how to work with them, but none gave me justification on how and when I should use greenlets! What are they really good at? Is it a good idea to use them in a proxy server or not? …

Total answers: 4