Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import multiprocessing as mp
- def process_data((id,db)):
- print 'in processdata'
- cursor = db.cursor()
- query = ....
- #cursor.execute(query)
- #....
- .....
- .....
- return row
- `if __name__ == '__main__':
- db = getConnection()
- cursor = db.cursor()
- print 'Initialised db connection and cursor'
- inputs = [1,2,3,4,5]
- pool = mp.Pool(processes=2)
- result_list = pool.map(process_data,zip(inputs,repeat(db)))
- #print result_list
- pool.close()
- pool.join()
- `Exception in thread Thread-1:
- Traceback (most recent call last):
- File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
- self.run()
- File "/usr/lib/python2.6/threading.py", line 484, in run
- self.__target(*self.__args, **self.__kwargs)
- File "/usr/lib/python2.6/multiprocessing/pool.py", line 225, in _handle_tasks
- put(task)
- PicklingError: Can't pickle <type 'module'>: attribute lookup __builtin__.module failed`
Add Comment
Please, Sign In to add comment