Multiprocessing Python/Q

Hello Everyone,

I am trying to use the multiprocessing capabilities of python to launch Q function on a server. But it seems that the processes cannot run in parallel. Indeed, using 1 or more processes does not change the running time.

the code looks like this:

if __name__== ‘__main__’:

    

    pool = mp.Pool(processes=3)

    start_time = time.time()    

    results = [pool.apply_async(Launch_Data_Extraction, args=(x,)) for x in list_]

    output = [p.get() for p in results]

    print(time.time()-start_time)

  

And Launch_Data_Extraction looks like 

def Launch_Data_Extraction(x):

   hdb = qconnection.QConnection(host=, port=,username=, pandas=True)

   DO STUFF

   return

x would be individual orders for example, they only share the same initial data in the server. I am essentially trying to multi process a for-loop.

Am I doing something wrong ? Someone can help on this please ?

Thanks in advance,

Anas

Hi Anas,

<o:p> </o:p>

I’m not entirely clear what you are trying to do but I would use kdb directly, with slaves, then call peach for parallel processing, e.g.

<o:p> </o:p>

Start q with 3 slaves, on port 5001

q -s 3 -p 5001

<o:p> </o:p>

Define and call your data extraction function from q

Launch_Data_Extraction: { DO-STUFF x } ;

Launch_Data_Extraction peach list_ ;

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

From: a im
Sent: Friday, 27 September 2019 18:04
To: Kdb+ Personal Developers
Subject: [personal kdb+] Multiprocessing Python/Q

<o:p> </o:p>

Hello Everyone,

<o:p> </o:p>

<o:p> </o:p>

I am trying to use the multiprocessing capabilities of python to launch Q function on a server. But it seems that the processes cannot run in parallel. Indeed, using 1 or more processes does not change the running time.

<o:p> </o:p>

the code looks like this:

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

if __name__== ‘__main__’:

    

    pool = mp.Pool(processes=3)

    start_time = time.time()    

    results = [pool.apply_async(Launch_Data_Extraction, args=(x,)) for x in list_]

    output = [p.get() for p in results]

    print(time.time()-start_time)

  

<o:p> </o:p>

And Launch_Data_Extraction looks like 

<o:p> </o:p>

def Launch_Data_Extraction(x):

   hdb = qconnection.QConnection(host=, port=,username=, pandas=True)

   DO STUFF

   return

<o:p> </o:p>

x would be individual orders for example, they only share the same initial data in the server. I am essentially trying to multi process a for-loop.

<o:p> </o:p>

Am I doing something wrong ? Someone can help on this please ?

<o:p> </o:p>

Thanks in advance,

Anas

<o:p> </o:p>

<o:p> </o:p>


Submitted via Google Groups