diff --git a/spiffworkflow-backend/bin/run_server_locally b/spiffworkflow-backend/bin/run_server_locally
index 3e9f712b6..0fa63d218 100755
--- a/spiffworkflow-backend/bin/run_server_locally
+++ b/spiffworkflow-backend/bin/run_server_locally
@@ -29,7 +29,13 @@ else
export FLASK_DEBUG=1
if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then
- SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
+ RUN_BACKGROUND_SCHEDULER=false SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
fi
- FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000
+
+ if [[ -z "${RUN_BACKGROUND_SCHEDULER:-}" ]]; then
+ RUN_BACKGROUND_SCHEDULER=true
+ fi
+
+ # this line blocks
+ RUN_BACKGROUND_SCHEDULER="${RUN_BACKGROUND_SCHEDULER}" FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000
fi
diff --git a/spiffworkflow-backend/poetry.lock b/spiffworkflow-backend/poetry.lock
index 2e001a93f..2758fe964 100644
--- a/spiffworkflow-backend/poetry.lock
+++ b/spiffworkflow-backend/poetry.lock
@@ -1787,7 +1787,7 @@ lxml = "*"
type = "git"
url = "https://github.com/sartography/SpiffWorkflow"
reference = "main"
-resolved_reference = "be26100bcbef8026e26312c665dae42faf476485"
+resolved_reference = "655e415e1522a8f4eb29c3e8531f74bf826b5ef4"
[[package]]
name = "SQLAlchemy"
diff --git a/spiffworkflow-backend/pyproject.toml b/spiffworkflow-backend/pyproject.toml
index 83a434821..1ec9375a5 100644
--- a/spiffworkflow-backend/pyproject.toml
+++ b/spiffworkflow-backend/pyproject.toml
@@ -28,7 +28,7 @@ flask-migrate = "*"
flask-restful = "*"
werkzeug = "*"
SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"}
-#SpiffWorkflow = {develop = true, path = "../SpiffWorkflow" }
+# SpiffWorkflow = {develop = true, path = "../SpiffWorkflow" }
sentry-sdk = "^1.10"
sphinx-autoapi = "^2.0"
flask-bpmn = {git = "https://github.com/sartography/flask-bpmn", rev = "main"}
diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py b/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py
index f67dccc05..eef7eb18e 100644
--- a/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py
+++ b/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py
@@ -125,7 +125,11 @@ def create_app() -> flask.app.Flask:
app.json = MyJSONEncoder(app)
- if app.config["RUN_BACKGROUND_SCHEDULER"]:
+ # do not start the scheduler twice in flask debug mode
+ if (
+ app.config["RUN_BACKGROUND_SCHEDULER"]
+ and os.environ.get("WERKZEUG_RUN_MAIN") != "true"
+ ):
start_scheduler(app)
configure_sentry(app)
diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/development.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/development.py
index 39e10cb58..b1ea980c2 100644
--- a/spiffworkflow-backend/src/spiffworkflow_backend/config/development.py
+++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/development.py
@@ -10,7 +10,7 @@ SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
)
RUN_BACKGROUND_SCHEDULER = (
- environ.get("RUN_BACKGROUND_SCHEDULER", default="true") == "true"
+ environ.get("RUN_BACKGROUND_SCHEDULER", default="false") == "true"
)
GIT_CLONE_URL_FOR_PUBLISHING = environ.get(
"GIT_CLONE_URL", default="https://github.com/sartography/sample-process-models.git"
diff --git a/spiffworkflow-backend/tests/data/call-activity-to-human-task/manual_task.bpmn b/spiffworkflow-backend/tests/data/call-activity-to-human-task/manual_task.bpmn
new file mode 100644
index 000000000..ff9c40003
--- /dev/null
+++ b/spiffworkflow-backend/tests/data/call-activity-to-human-task/manual_task.bpmn
@@ -0,0 +1,42 @@
+
+
+
+
+ Flow_1nxz6rd
+
+
+
+ Flow_1jtitb1
+
+
+
+
+ NOOOOOOOOOOOOOOOOOO!!!!!!!!!!
+
+ Flow_1nxz6rd
+ Flow_1jtitb1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spiffworkflow-backend/tests/data/call-activity-to-human-task/primary_process.bpmn b/spiffworkflow-backend/tests/data/call-activity-to-human-task/primary_process.bpmn
new file mode 100644
index 000000000..8278559b8
--- /dev/null
+++ b/spiffworkflow-backend/tests/data/call-activity-to-human-task/primary_process.bpmn
@@ -0,0 +1,39 @@
+
+
+
+
+ Flow_0fdzi5f
+
+
+
+ Flow_0ii0wgu
+
+
+
+ Flow_0fdzi5f
+ Flow_0ii0wgu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py
new file mode 100644
index 000000000..bacde125b
--- /dev/null
+++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py
@@ -0,0 +1,46 @@
+"""Test_process_instance_processor."""
+import os
+from flask.app import Flask
+from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
+from tests.spiffworkflow_backend.helpers.base_test import BaseTest
+from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
+
+from spiffworkflow_backend.models.user import UserModel
+from spiffworkflow_backend.services.process_instance_processor import (
+ ProcessInstanceProcessor,
+)
+
+
+class TestProcessInstanceService(BaseTest):
+ """TestProcessInstanceService."""
+
+ def test_does_not_log_set_data_when_calling_engine_steps_on_waiting_call_activity(
+ self,
+ app: Flask,
+ with_db_and_bpmn_file_cleanup: None,
+ with_super_admin_user: UserModel,
+ ) -> None:
+ """Test_does_not_log_set_data_when_calling_engine_steps_on_waiting_call_activity."""
+ tmp_file = '/tmp/testfile.txt'
+ if os.path.isfile(tmp_file):
+ os.remove(tmp_file)
+ process_model = load_test_spec(
+ process_model_id="test_group/call-activity-to-human-task",
+ process_model_source_directory="call-activity-to-human-task",
+ )
+ process_instance = self.create_process_instance_from_process_model(
+ process_model=process_model, user=with_super_admin_user
+ )
+ processor = ProcessInstanceProcessor(process_instance)
+ processor.do_engine_steps(save=True)
+
+ process_instance_logs = SpiffLoggingModel.query.filter_by(process_instance_id=process_instance.id).all()
+ initial_length = len(process_instance_logs)
+
+ # logs should NOT increase after running this a second time since it's just waiting on a human task
+ print("HEY NOW")
+ with open(tmp_file, 'w') as f:
+ f.write("HEY")
+ processor.do_engine_steps(save=True)
+ process_instance_logs = SpiffLoggingModel.query.filter_by(process_instance_id=process_instance.id).all()
+ assert len(process_instance_logs) == initial_length