Skip to content

Commit d42e125

Browse files
committed
Set some context earlier.
Hopefully prevents 500 error if job error.
1 parent f6fed52 commit d42e125

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

web.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,21 @@ def _split(fr, to, day, time, time_ret):
197197
if to in data['stations_by_name']: to = data['stations_by_name'][to]['code']
198198
bottle.redirect(make_url(fr=fr, to=to))
199199

200+
context.update({
201+
'fr_desc': data['stations'][fr]['description'],
202+
'to_desc': data['stations'][to]['description'],
203+
'url_job': make_url(),
204+
})
205+
200206
q = Queue(connection=R)
201207
job_id = get_job_id(context)
202208
job = q.fetch_job(job_id)
203209
include_me = 0
204210

205211
if job and (job.is_finished or job.is_failed):
206-
if not job.result or 'error' in job.result: return error(job.result)
212+
if not job.result or 'error' in job.result:
213+
context.update(job.result or {})
214+
return error(context)
207215
return split_finished(job.result)
208216

209217
if job:
@@ -218,9 +226,6 @@ def _split(fr, to, day, time, time_ret):
218226
busy_workers = len([ w for w in Worker.all(connection=R) if w.get_state() == 'busy' ]) - include_me
219227
busy_workers += q.count
220228
context.update({
221-
'fr_desc': data['stations'][fr]['description'],
222-
'to_desc': data['stations'][to]['description'],
223-
'url_job': make_url(),
224229
'refresh': max(1, busy_workers),
225230
'queue_size': max(0, busy_workers),
226231
})

0 commit comments

Comments
 (0)