Search code examples
pythonwps

Pywps Timeout long processes (Asynchronous request)


I'm executing a long process WPS of around 180sec, and when it start after 60sec the WPS (response) is abandoned, and the process continue to run until the end (checked on the log file).

I tried the solution proposed by Pywps wiki of reducing the timeout of the Apache server (http://wiki.rsg.pml.ac.uk/pywps/Async_issue) without success !

I found the response which seems to be the only issue : http://lists.wald.intevation.org/pipermail/pywps-devel/2013-April/001598.html But I didn't find how can I insert my "call process" by self.cmd("process.sh...).

Also this kind of statue check don't return back the literal output ! :

Any help will be appreciate.

Here is the wps example:

from pywps.Process.Process import WPSProcess
import time
import sys
from datetime import datetime

start=datetime.now()

class Process(WPSProcess):
    def __init__(self):
        # initialisation process
        WPSProcess.__init__(self,
            identifier="timeout_test",      
            title="timeout test",
            version = "1.0", 
            storeSupported = True,
            statusSupported = True,
            abstract="Ce WPS permet de tester les long processes")
    # Total sleep time
            self.delay = self.addLiteralInput(identifier = "delay",
            title = "Time delay in seconds.",
            abstract = "Field of type INTEGER specifying a time delay in seconds.",
            type = type(1.0),       
            default = 180)

Output

    self.num = self.addLiteralOutput(identifier="num",
                                     title="A sample literal output.")

Execution

def execute(self):

    # Time sleep
    self.status.set("getting ready", 1)

    self.num.setValue(0)
    sys.stdout.flush()
    step = self.delay.getValue()/6

    for i in range(6):
        self.status.set("Processing...", i*10)
        sys.stdout.flush()
        time.sleep(step)


    self.status.set("Finishing", 100)

    self.num.setValue("Temps du traitement : " + str(datetime.now()-start)+"\n")

    return

Solution

  • The problem came from the Qgis WPS client, he abandoned the application process lasting more than 60 minutes! I used an openlayers client, it worked well in asynchronous mode, of course, once the timeout instance of PyWPS and Apache have been set up.