multiprocessing from multiprocessing import pool def collect_results(result)print('in collect_results'resultdef worker( )print('in worker with'xreturn def main()with pool(processes= as poolget based example res pool apply_async(worker[ ]print('result from async'res get(timeout= )with pool(processes= as poolcallback based example pool apply_async(workerargs=[ ]callback=collect_resultsif __name__ ='__main__'main(the output from this isin worker with result from async in worker with in collect_results exchanging data between processes in some situations it is necessary for two processes to exchange data howeverthe two process objects do not share memory as they are running in separate operating system level processes to get around this the multiprocessing library provides the pipe(function the pipe(function returns pair of connection connection objects connected by pipe which by default is duplex (two-waythe two connection objects returned by pipe(represent the two ends of the pipe each connection object has send(and recv(methods (among othersthis allows one process to send data via the send(method of one end of the connection object in turn second process can receive that data via the receive (method of the other connection object this is illustrated below