Skip to content

Commit

Permalink
Merge pull request bird-house#36 in OGC/testbed14-twitcher from rando…
Browse files Browse the repository at this point in the history
…m_fixes to dynamic-wps-processes

* commit '0e62e133cca1e1e092435d0fdc41620d2a7c544a':
  Raise an internal server error if a new job status is unavailbale after max_retry seconds
  Return only from execute request when job status is available
  • Loading branch information
dbyrns committed Nov 21, 2018
2 parents 588bcff + 0e62e13 commit 62f6523
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions twitcher/wps_restapi/processes/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pyramid.httpexceptions import *
from pyramid.settings import asbool
from pyramid_celery import celery_app as app
from pyramid.request import Request
from celery.utils.log import get_task_logger
from six.moves.urllib.parse import urlparse
from six.moves.urllib.request import urlopen
Expand Down Expand Up @@ -343,6 +344,26 @@ def submit_job_handler(request, service_url, is_workflow=False):
location_base=location_base,
process_id=process_id,
job_id=result.id)

retry = 0
max_retry = 5
while True:
try:
subreq = Request.blank(location)
response = request.invoke_subrequest(subreq)
if response.status_code == HTTPOk.code:
break
except HTTPNotFound:
# It's expected, raise any other exception
pass

retry += 1
if retry > max_retry:
raise HTTPInternalServerError('Submit job failed. Status is unavailable after {0} seconds'
.format(max_retry))
else:
sleep(1)

body_data = {
'jobID': result.id,
'status': STATUS_ACCEPTED,
Expand Down

0 comments on commit 62f6523

Please sign in to comment.