python-multiprocessing

Why is the parallel version of my code slower than the serial one?

Why is the parallel version of my code slower than the serial one? Question: I am trying to run a model multiple times. As a result it is time consuming. As a solution I try to make it parallel. However, it ends up to be slower. Parallel is 40 seconds while serial is 34 seconds. …

Total answers: 1

SCOOP – How to make workers wait for root worker before continuing

SCOOP – How to make workers wait for root worker before continuing Question: I am using SCOOP (and Python 3.6 – cannot be updated) in my work. I need all workers to perform a computation, then wait for the root node to execute a slow computation (the code in a if __name__ == ‘__main__’:), then …

Total answers: 1

Get list of tuples of stacked for loop values

Get list of tuples of stacked for loop values Question: While trying to speed up: l = some_value for i in range(1000): for j in range(1000): for k in range(1000): function(i, j, k, l) I stumbled upon multiprocessing.Pool().starmap() however it requires the iterated values to be passed in as an interator [(0, 0, 0), (1, …

Total answers: 1

PySpark executing queries from different processes

PySpark executing queries from different processes Question: Is there any way to have two separate processes executing queries on Spark? Something like: def process_1(): spark_context = SparkSession.builder.getOrCreate() data1 = spark_context.sql("SELECT * FROM table 1").toPandas() do_processing(data1) def process_2(): spark_context = SparkSession.builder.getOrCreate() data1 = spark_context.sql("SELECT * FROM table 2").toPandas() do_processing(data1) p1 = Process(target=process_1) p1.start() p2 = Process(target=process_2) …

Total answers: 1

SSL pickle error when running multiprocess inside class's method and websocket

SSL pickle error when running multiprocess inside class's method and websocket Question: I am creating a phyton object that establishes a websocket connection. Depending the message that I receive, I would like to run a class’s method on a child-process using multiprocessing. However, I get the error cannot pickle ‘SSLSocket’ object. Why does it happen? …

Total answers: 1

Multiprocessing in python – saving memory by adding results

Multiprocessing in python – saving memory by adding results Question: I’m simulating a physical problem under different initial conditions using Python. As these realizations are completely independent of each other, I wanted to use the multiprocessing package. Now, the result of one realization can easily be a few 100 Mb large (eg. 20 frames with …

Total answers: 1

how to convert nested loops with body to parallelized iterables for multiprocessing

how to convert nested loops with body to parallelized iterables for multiprocessing Question: i have the below two nested loops. i want to use them as iterables passed to .map operator to parallelize their execution.i am familiar with the following notation: with PoolExec(max_workers=int(config[‘MULTIPROCESSING’][‘proceses_count’]),initializer=self.initPool,initargs=(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,)) as GridCells10mX10mIteratorPool.__poolExec: self.__chunkSize = PoolUtils.getChunkSizeForLenOfIterables(lenOfIterablesList=self.__maxNumOfCellsVertically*self.__maxNumOfCellsHorizontally,cpuCount=int(config[‘MULTIPROCESSING’][‘cpu_count’])) for res in GridCells10mX10mIteratorPool.__poolExec.map(self.run,[(i,j) for i in …

Total answers: 2