I have a python script that runs a set of queries in parallel using multiprocessing.pool and map_async.
The script from @Aaron works perfectly.
Now I want to integrate the same functions into a PyWPS service, but I do not succeed. The processing does not start and I get no error in return.
Here is my PyWPS script:
import os, sys
from pywps.Process.Process import WPSProcess
import multiprocessing
from multiprocessing import Pool
from pg import DB
from functools import partial....
db = DB(dbname='****', host='****', port=****, user='****', passwd='****')
class Process(WPSProcess):
def __init__(self):
# init process
WPSProcess.__init__(self,...)
self.input1 = ...
self.output1 = ...
def execute(self):
tup = db.query("""
SELECT distinct code_cc from comm_pop limit 200
""").getresult()
code_list = list(zip(*tup)[0])
db.query("""DROP TABLE IF EXISTS tpop.tpop_sample""")
db.query("""CREATE TABLE IF NOT EXISTS tpop.tpop_sample(...)""")
pool = multiprocessing.Pool(processes=7)
func = partial(self.tpop, self.input1.getValue())
pool.map_async(func, code_list)
pool.close()
pool.join()
out = db.query("""SELECT * from tpop.tpop_sample""").getresult()
self.output1.setValue(out)
def tpop(self, tabcouv, code):
db.query("""
INSERT INTO tpop.tpop_sample...do something"""% (tabcouv, code, code))
I have no error message in the pywps log file, I have only an info message:
INFO: Status [processstarted][0.0]: Process pop started
I have already tested without the multiprocessing and I got results.
For information I'am using PyWPS 3.2.5 with Python 2.7