From c19e59757d572d8503200de874464b14f356560d Mon Sep 17 00:00:00 2001 From: jbirddog <100367399+jbirddog@users.noreply.github.com> Date: Mon, 24 Apr 2023 15:39:49 -0400 Subject: [PATCH] Interstitial page locking fix (#228) Tested on dev.app by @burnettk @jasquat @calexh-sar --- .../spiffworkflow_backend/routes/tasks_controller.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 34d9ec851..872b25213 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -383,8 +383,7 @@ def _render_instructions_for_end_user(task_model: TaskModel, extensions: Optiona return "" -def _interstitial_stream(process_instance_id: int) -> Generator[str, Optional[str], None]: - process_instance = _find_process_instance_by_id_or_raise(process_instance_id) +def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[str, Optional[str], None]: processor = ProcessInstanceProcessor(process_instance) reported_ids = [] # bit of an issue with end tasks showing as getting completed twice. 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" +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: """A Server Side Events Stream for watching the execution of engine tasks.""" return Response( - stream_with_context(_interstitial_stream(process_instance_id)), + stream_with_context(_dequeued_interstitial_stream(process_instance_id)), mimetype="text/event-stream", headers={"X-Accel-Buffering": "no"}, )