Problem with multiprocessing library in Python

KristaBel report abuse

I need to speed up the execution of my code. After I had written the synchronized version of my code, I have measured the execution time. The same I did after I rewrite the code and implemented multiprocessing. I have checked it many times and it seems that there are no bugs. However, the speed gain is insignificant. I expected that it should be several times faster, but it is not. What can be wrong?


PyAnto report abuse

Hi @KristaBel

Concurrency and multiprocessing are hard topics to debug and optimize. What I would check first is, whether multiprocessing is the right library for your use case. There are some tasks where it is better to use asyncio or threading packages.


KristaBel report abuse

My task is to make the process of communication with the API and database faster. I need to perform many requests over the network and many SQL queries to my local database. Is it OK to use multiprocessing for this task?

PyAnto report abuse

Hi @KristaBel I am almost confident that multiprocessing is not the right choice here. Try to use asyncio or at least threading.

Add Answer

Need support?

Just drop us an email to ... Show more