wait 120 seconds before processing user_input_required process instances w/ burnettk
This commit is contained in:
parent
612d63f141
commit
6e23a179b7
|
@ -76,6 +76,11 @@ def start_scheduler(
|
|||
"interval",
|
||||
seconds=10,
|
||||
)
|
||||
scheduler.add_job(
|
||||
BackgroundProcessingService(app).process_user_input_required_process_instances,
|
||||
"interval",
|
||||
seconds=120,
|
||||
)
|
||||
scheduler.start()
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Background_processing_service."""
|
||||
import flask
|
||||
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
|
||||
from spiffworkflow_backend.services.message_service import MessageService
|
||||
from spiffworkflow_backend.services.process_instance_service import (
|
||||
ProcessInstanceService,
|
||||
|
@ -19,6 +20,13 @@ class BackgroundProcessingService:
|
|||
with self.app.app_context():
|
||||
ProcessInstanceService.do_waiting()
|
||||
|
||||
def process_user_input_required_process_instances(self) -> None:
|
||||
"""Since this runs in a scheduler, we need to specify the app context as well."""
|
||||
with self.app.app_context():
|
||||
ProcessInstanceService.do_waiting(
|
||||
ProcessInstanceStatus.user_input_required.value
|
||||
)
|
||||
|
||||
def process_message_instances_with_app_context(self) -> None:
|
||||
"""Since this runs in a scheduler, we need to specify the app context as well."""
|
||||
with self.app.app_context():
|
||||
|
|
|
@ -7,7 +7,6 @@ from typing import Optional
|
|||
import sentry_sdk
|
||||
from flask import current_app
|
||||
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
|
||||
from sqlalchemy import or_
|
||||
|
||||
from spiffworkflow_backend import db
|
||||
from spiffworkflow_backend.exceptions.api_error import ApiError
|
||||
|
@ -71,17 +70,11 @@ class ProcessInstanceService:
|
|||
return cls.create_process_instance(process_model, user)
|
||||
|
||||
@staticmethod
|
||||
def do_waiting() -> None:
|
||||
def do_waiting(status_value: str = ProcessInstanceStatus.waiting.value) -> None:
|
||||
"""Do_waiting."""
|
||||
records = (
|
||||
db.session.query(ProcessInstanceModel)
|
||||
.filter(
|
||||
or_(
|
||||
ProcessInstanceModel.status == ProcessInstanceStatus.waiting.value,
|
||||
ProcessInstanceModel.status
|
||||
== ProcessInstanceStatus.user_input_required.value,
|
||||
)
|
||||
)
|
||||
.filter(ProcessInstanceModel.status == status_value)
|
||||
.all()
|
||||
)
|
||||
process_instance_lock_prefix = "Background"
|
||||
|
|
Loading…
Reference in New Issue