def launch_next_process(self): """Look at the queue of async process, if the queue is not empty launch the next pending request. """ try: LOGGER.debug("Checking for stored requests") stored_request = dblog.pop_first_stored() if not stored_request: LOGGER.debug("No stored request found") return (uuid, request_json) = (stored_request.uuid, stored_request.request) if not PY2: request_json = request_json.decode('utf-8') LOGGER.debug("Launching the stored request {}".format(str(uuid))) new_wps_request = WPSRequest() new_wps_request.json = json.loads(request_json) process_identifier = new_wps_request.identifier process = self.service.prepare_process_for_execution( process_identifier) process._set_uuid(uuid) process.async_ = True new_wps_response = ExecuteResponse(new_wps_request, process=process, uuid=uuid) new_wps_response.store_status_file = True process._run_async(new_wps_request, new_wps_response) except Exception as e: LOGGER.exception("Could not run stored process. {}".format(e))
def launch_next_process(self): """Look at the queue of async process, if the queue is not empty launch the next pending request. """ try: LOGGER.debug("Checking for stored requests") stored_request = dblog.pop_first_stored() if not stored_request: LOGGER.debug("No stored request found") return (uuid, request_json) = (stored_request.uuid, stored_request.request) if not PY2: request_json = request_json.decode('utf-8') LOGGER.debug("Launching the stored request {}".format(str(uuid))) new_wps_request = WPSRequest() new_wps_request.json = json.loads(request_json) process_identifier = new_wps_request.identifier process = self.service.prepare_process_for_execution(process_identifier) process._set_uuid(uuid) process.async_ = True new_wps_response = ExecuteResponse(new_wps_request, process=process, uuid=uuid) new_wps_response.store_status_file = True process._run_async(new_wps_request, new_wps_response) except Exception as e: LOGGER.exception("Could not run stored process. {}".format(e))
def from_json(cls, value): """init this request from json back again :param value: the json (not string) representation """ process = Process.from_json(value['process']) wps_request = WPSRequest() wps_request.json = json.loads(value['wps_request']) wps_response = ExecuteResponse(wps_request=wps_request, uuid=process.uuid, process=process) wps_response.store_status_file = True new_job = Job(process=Process.from_json(value['process']), wps_request=wps_request, wps_response=wps_response) return new_job
def setUp(self): self.uuid = uuid.uuid1() self.dummy_process = InOut() self.dummy_process._set_uuid(self.uuid) self.dummy_process.set_workdir('/tmp') self.wps_request = WPSRequest() self.wps_response = ExecuteResponse(self.wps_request, self.uuid, process=self.dummy_process) self.job = Job( process=self.dummy_process, wps_request=self.wps_request, wps_response=self.wps_response)
def setUp(self): def handler(request, response): response.outputs['output'].data = '42' return response self.uuid = 1234 self.dummy_process = Process( handler=handler, identifier='dummy', title='Dummy Process', outputs=[LiteralOutput('output', 'Output', data_type='string')]) self.wps_request = WPSRequest() self.wps_response = ExecuteResponse(self.wps_request, self.uuid, process=self.dummy_process)