python - Unable to send pandas dataframe object to SQL when using multiprocessing module -


i transforming single dataframe using multiple cpu cores , want insert result mysql.

using below code observed 1 active cpu core , no updates mysql. no error messages produced.

the original dataframe pandas_df never altered. transformations pandas_df stored in result_df.

the code has been verified work correctly in serial.

import multiprocessing mp sqlalchemy import create_engine engine = create_engine(mysql_string)  def function(pandas_df, tuple, engine):     #slice , dice pandas_df according tuple     result_df.to_sql("table_name", engine, if_exists='append')   pool = mp.pool(processes=4) tuple in tuples:     pool.apply_async(est, args=(pandas_df, tuple, engine)) 

most of tutorials , guides came across passed strings inside args=(). there articles demonstrate ability pass numpy arrays: http://sebastianraschka.com/articles/2014_multiprocessing_intro.html

i have tried above code using map_async() method and/or inserting return statement inside function , there no difference in behaviour.

i open trying different python modules. need solution transforms single dataframe in parallel , inserts result database.

you need make sure function has access variables otherwise silent failure may occur.


Comments