Interstitial page locking fix (#228)

Tested on dev.app by @burnettk @jasquat @calexh-sar
This commit is contained in:
jbirddog 2023-04-24 15:39:49 -04:00 committed by GitHub
parent 7fb5c82bbc
commit 17b01444a9
1 changed files with 7 additions and 3 deletions

View File

@ -383,8 +383,7 @@ def _render_instructions_for_end_user(task_model: TaskModel, extensions: Optiona
return "" return ""
def _interstitial_stream(process_instance_id: int) -> Generator[str, Optional[str], None]: def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[str, Optional[str], None]:
process_instance = _find_process_instance_by_id_or_raise(process_instance_id)
processor = ProcessInstanceProcessor(process_instance) processor = ProcessInstanceProcessor(process_instance)
reported_ids = [] # bit of an issue with end tasks showing as getting completed twice. reported_ids = [] # bit of an issue with end tasks showing as getting completed twice.
spiff_task = processor.next_task() spiff_task = processor.next_task()
@ -427,10 +426,15 @@ def _interstitial_stream(process_instance_id: int) -> Generator[str, Optional[st
yield f"data: {current_app.json.dumps(task)} \n\n" yield f"data: {current_app.json.dumps(task)} \n\n"
def _dequeued_interstitial_stream(process_instance_id: int) -> Generator[str, Optional[str], None]:
process_instance = _find_process_instance_by_id_or_raise(process_instance_id)
with ProcessInstanceQueueService.dequeued(process_instance):
yield from _interstitial_stream(process_instance)
def interstitial(process_instance_id: int) -> Response: def interstitial(process_instance_id: int) -> Response:
"""A Server Side Events Stream for watching the execution of engine tasks.""" """A Server Side Events Stream for watching the execution of engine tasks."""
return Response( return Response(
stream_with_context(_interstitial_stream(process_instance_id)), stream_with_context(_dequeued_interstitial_stream(process_instance_id)),
mimetype="text/event-stream", mimetype="text/event-stream",
headers={"X-Accel-Buffering": "no"}, headers={"X-Accel-Buffering": "no"},
) )