[Pywps-dev] Problem calling a WPS service from another WPS service

Lorenzo Bottaccioli lorenzo.bottaccioli at gmail.com
Tue Jun 21 01:58:34 PDT 2016


Hi Jachym,

Is there any guide or suggestion to how set-up PyWPS4 with Apache2 or
nginx? Do you think that I can use Cherrypy?

best,

Lorenzo

2016-06-19 10:23 GMT+02:00 Jachym Cepicky <jachym.cepicky at gmail.com>:

> Hi Lorenzo,
>
> the problem could be that you use flask in single thread mode - therefore
> it can handle only one request at time. [1] it should be possible to switch
> to multihread mode, but consider for this case to setup some real web
> server, like Apache2 or nginx
>
> J
>
> [1]
> http://stackoverflow.com/questions/14814201/can-i-serve-multiple-clients-using-just-flask-app-run-as-standalone
>
> ne 19. 6. 2016 v 0:54 odesílatel Lorenzo Bottaccioli <
> lorenzo.bottaccioli at gmail.com> napsal:
>
>> Hi Jachym,
>>
>> Yes is using flask, I just ad process to the demo.py.
>>
>> Best, Lorenzo
>> Il 18 giu 2016 11:40 PM, "Jachym Cepicky" <jachym.cepicky at gmail.com> ha
>> scritto:
>>
>>> Lorenzo,
>>>
>>> are you using flask server or what WebServer are you using?
>>>
>>> J
>>>
>>> pá 10. 6. 2016 v 16:26 odesílatel Lorenzo Bottaccioli <
>>> lorenzo.bottaccioli at gmail.com> napsal:
>>>
>>>> Hi list,
>>>>
>>>> I'm having a problem with a service when I call another service inside
>>>> the process.
>>>>
>>>>    def _handler(self, request, response):
>>>>
>>>>          df = self.get_real_sky(geodf,start,end,model)
>>>>
>>>>     def get_real_sky(self,geodf,start,end,model):
>>>>         #print 'eccolo dentro'
>>>>         import requests
>>>>         url = "http://130.192.5.114:8080/wps"
>>>>
>>>>         payload = "<wps:Execute service=\"WPS\" version=\"1.0.0\"
>>>> xmlns:wps=\"http://www.opengis.net/wps/1.0.0\" xmlns:ows=\"
>>>> http://www.opengis.net/ows/1.1\" xmlns:xlink=\"
>>>> http://www.w3.org/1999/xlink\" xmlns:xsi=\"
>>>> http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"
>>>> http://www.opengis.net/wps/1.0.0\n../wpsExecute_request.xsd\">\n
>>>> <ows:Identifier>real_sky</ows:Identifier>\n  <wps:DataInputs>\n
>>>>  <wps:Input>\n      <ows:Identifier>layer_in</ows:Identifier>\n
>>>>  <wps:Data>\n    <wps:ComplexData>"+geodf.to_json()+"</wps:ComplexData>\n
>>>>  </wps:Data>\n    </wps:Input>\n    <wps:Input>\n
>>>>  <ows:Identifier>start</ows:Identifier>\n        <wps:Data>\n
>>>>  <wps:LiteralData dataType=\"xs:string\">"+start+"</wps:LiteralData>\n
>>>>    </wps:Data>\n    </wps:Input>\n    <wps:Input>\n
>>>>  <ows:Identifier>end</ows:Identifier>\n        <wps:Data>\n
>>>>  <wps:LiteralData dataType=\"xs:string\">"+end+"</wps:LiteralData>\n
>>>>  </wps:Data>\n    </wps:Input>\n    <wps:Input>\n
>>>>  <ows:Identifier>model</ows:Identifier>\n        <wps:Data>\n
>>>>  <wps:LiteralData dataType=\"xs:string\">"+model+"</wps:LiteralData>\n
>>>>    </wps:Data>\n    </wps:Input>\n  </wps:DataInputs>\n
>>>>  <wps:ResponseForm>\n    <wps:RawDataOutput>\n
>>>>  <ows:Identifier>layer_out</ows:Identifier>\n    </wps:RawDataOutput>\n
>>>>  </wps:ResponseForm>\n</wps:Execute>"
>>>>         headers = {
>>>>             'content-type': "application/xml",
>>>>             'cache-control': "no-cache",
>>>>             'postman-token': "78829681-df08-3317-2e0e-90a31ea4f2a6"
>>>>             }
>>>>
>>>>         response = requests.request("POST", url, data=payload,
>>>> headers=headers)
>>>>
>>>>         return response.text
>>>>
>>>>
>>>> The process inside def get_real_sky works if I call it by it self, but
>>>> if I call inside another process dosent work, it simply blocks and do not
>>>> go forward. I have tried to run only the service real_sky in another port
>>>> not in 8080 like the one who calls it but in 8082. In this way it works. I
>>>> dont understand if the problem is Flask or the problem is PyWPS.
>>>>
>>>> If I press crtl+c to stop the process I get this:
>>>>
>>>> Exception happened during processing of request from ('130.192.5.114',
>>>> 49246)
>>>> Traceback (most recent call last):
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 295, in
>>>> _handle_request_noblock
>>>>     self.process_request(request, client_address)
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 321, in
>>>> process_request
>>>>     self.finish_request(request, client_address)
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
>>>>     self.RequestHandlerClass(request, client_address, self)
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
>>>>     self.handle()
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/serving.py",
>>>> line 216, in handle
>>>>     rv = BaseHTTPRequestHandler.handle(self)
>>>>   File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
>>>>     self.handle_one_request()
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/serving.py",
>>>> line 251, in handle_one_request
>>>>     return self.run_wsgi()
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/serving.py",
>>>> line 193, in run_wsgi
>>>>     execute(self.server.app)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/serving.py",
>>>> line 181, in execute
>>>>     application_iter = app(environ, start_response)
>>>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line
>>>> 1836, in __call__
>>>>     return self.wsgi_app(environ, start_response)
>>>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line
>>>> 1817, in wsgi_app
>>>>     response = self.full_dispatch_request()
>>>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line
>>>> 1478, in full_dispatch_request
>>>>     response = self.make_response(rv)
>>>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line
>>>> 1577, in make_response
>>>>     rv = self.response_class.force_type(rv, request.environ)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/wrappers.py",
>>>> line 847, in force_type
>>>>     response = BaseResponse(*_run_wsgi_app(response, environ))
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/wrappers.py",
>>>> line 57, in _run_wsgi_app
>>>>     return _run_wsgi_app(*args)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/test.py",
>>>> line 871, in run_wsgi_app
>>>>     app_rv = app(environ, start_response)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/wrappers.py",
>>>> line 291, in application
>>>>     return f(*args[:-2] + (request,))(*args[-2:])
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Service.py",
>>>> line 529, in __call__
>>>>     request_uuid
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Service.py",
>>>> line 296, in execute
>>>>     response = self._parse_and_execute(process, wps_request, uuid)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Service.py",
>>>> line 358, in _parse_and_execute
>>>>     wps_response = process.execute(wps_request, uuid)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Process.py",
>>>> line 145, in execute
>>>>     wps_response = self._run_process(wps_request, wps_response)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Process.py",
>>>> line 151, in _run_process
>>>>     wps_response = self.handler(wps_request, wps_response)
>>>>   File
>>>> "/home/lorenzo/tools/pywps-4/pywps-4-demo/processes/solar/PV_NOCT.py", line
>>>> 45, in _handler
>>>>     df = self.get_real_sky(geodf,start,end,model)
>>>>   File
>>>> "/home/lorenzo/tools/pywps-4/pywps-4-demo/processes/solar/PV_NOCT.py", line
>>>> 101, in get_real_sky
>>>>     response = requests.request("POST", url, data=payload,
>>>> headers=headers)
>>>>   File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in
>>>> request
>>>>     return session.request(method=method, url=url, **kwargs)
>>>>   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line
>>>> 455, in request
>>>>     resp = self.send(prep, **send_kwargs)
>>>>   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line
>>>> 558, in send
>>>>     r = adapter.send(request, **kwargs)
>>>>   File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line
>>>> 330, in send
>>>>     timeout=timeout
>>>>   File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py",
>>>> line 562, in urlopen
>>>>     body=body, headers=headers)
>>>>   File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py",
>>>> line 414, in _make_request
>>>>     httplib_response = conn.getresponse(buffering=True)
>>>>   File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse
>>>>     response.begin()
>>>>   File "/usr/lib/python2.7/httplib.py", line 415, in begin
>>>>     version, status, reason = self._read_status()
>>>>   File "/usr/lib/python2.7/httplib.py", line 371, in _read_status
>>>>     line = self.fp.readline(_MAXLINE + 1)
>>>>   File "/usr/lib/python2.7/socket.py", line 476, in readline
>>>>     data = self._sock.recv(self._rbufsize)
>>>> KeyboardInterrupt
>>>> ----------------------------------------
>>>> 130.192.5.114 - - [10/Jun/2016 16:25:45] "POST /wps HTTP/1.1" 200 -
>>>> INFO:werkzeug:130.192.5.114 - - [10/Jun/2016 16:25:45] "POST /wps
>>>> HTTP/1.1" 200 -
>>>> ----------------------------------------
>>>> Exception happened during processing of request from ('130.192.5.114',
>>>> 49248)
>>>> Traceback (most recent call last):
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 295, in
>>>> _handle_request_noblock
>>>>     self.process_request(request, client_address)
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 321, in
>>>> process_request
>>>>     self.finish_request(request, client_address)
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
>>>>     self.RequestHandlerClass(request, client_address, self)
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
>>>>     self.finish()
>>>>   File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
>>>>     self.wfile.close()
>>>>   File "/usr/lib/python2.7/socket.py", line 279, in close
>>>>     self.flush()
>>>>   File "/usr/lib/python2.7/socket.py", line 303, in flush
>>>>     self._sock.sendall(view[write_offset:write_offset+buffer_size])
>>>> error: [Errno 32] Broken pipe
>>>> ----------------------------------------
>>>>
>>>>
>>>> Any suggestion?
>>>>
>>>> Best,
>>>>
>>>> Lorenzo
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> pywps-dev mailing list
>>>> pywps-dev at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/pywps-dev
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20160621/4dea501e/attachment-0001.html>


More information about the pywps-dev mailing list