diff --git a/README.md b/README.md index c83b98daf0..ced6e9bd2c 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ The action component listens to port 9002. The presenter component listens to po * `OPENSLIDES_BACKEND_THREAD_WATCH_TIMEOUT` - Seconds after which an action is delegated to an action worker. `-1` deactivates action workers all together. Default: `1.0` + Seconds after which an action is delegated to an action worker. `-1` represents an infinite timeout. `-2` deactivates action workers and local threading alltogether. Default: `1` ### Development diff --git a/global/meta/models.yml b/global/meta/models.yml index 09f3d379ad..23eb7c9acd 100644 --- a/global/meta/models.yml +++ b/global/meta/models.yml @@ -3846,6 +3846,10 @@ import_preview: name: type: string required: true + enum: + - account + - participant + - topic restriction_mode: A state: type: string diff --git a/openslides_backend/action/action_worker.py b/openslides_backend/action/action_worker.py index bae1496f14..f6bdcb4014 100644 --- a/openslides_backend/action/action_worker.py +++ b/openslides_backend/action/action_worker.py @@ -43,6 +43,12 @@ def handle_action_in_worker_thread( lock, internal, ) + timeout = float(handler.env.OPENSLIDES_BACKEND_THREAD_WATCH_TIMEOUT) + if timeout == -2: + # do not use action workers at all + action_worker_thread.run() + return action_worker_thread.response + curr_thread = cast(OSGunicornThread, threading.current_thread()) curr_thread.action_worker_writing = action_worker_writing curr_thread.action_worker_thread = action_worker_thread @@ -50,7 +56,6 @@ def handle_action_in_worker_thread( while not action_worker_thread.started: sleep(0.001) # The action_worker_thread should gain the lock and NOT this one - timeout = float(handler.env.OPENSLIDES_BACKEND_THREAD_WATCH_TIMEOUT) if lock.acquire(timeout=timeout): lock.release() if hasattr(action_worker_thread, "exception"): diff --git a/openslides_backend/models/models.py b/openslides_backend/models/models.py index ae32efe3b8..9560ab04e2 100644 --- a/openslides_backend/models/models.py +++ b/openslides_backend/models/models.py @@ -4,7 +4,7 @@ from .base import Model from .mixins import AgendaItemModelMixin, MeetingModelMixin, PollModelMixin -MODELS_YML_CHECKSUM = "245195a7e4707073f685fd2a0e43829b" +MODELS_YML_CHECKSUM = "d72f341534e83d6f62b306f9c7de7dc8" class Organization(Model): @@ -2124,7 +2124,9 @@ class ImportPreview(Model): verbose_name = "import preview" id = fields.IntegerField() - name = fields.CharField(required=True) + name = fields.CharField( + required=True, constraints={"enum": ["account", "participant", "topic"]} + ) state = fields.CharField( required=True, constraints={"enum": ["warning", "error", "done"]} ) diff --git a/requirements/partial/requirements_development.txt b/requirements/partial/requirements_development.txt index 96fdfa45ef..d390f8aa85 100644 --- a/requirements/partial/requirements_development.txt +++ b/requirements/partial/requirements_development.txt @@ -3,7 +3,7 @@ autoflake==2.2.1 black==23.11.0 debugpy==1.8.0 flake8==6.1.0 -isort==5.12.0 +isort==5.13.0 mypy==1.7.1 pip-check==2.8.1 pytest==7.4.3 diff --git a/requirements/partial/requirements_production.txt b/requirements/partial/requirements_production.txt index c38802a441..265b9354e6 100644 --- a/requirements/partial/requirements_production.txt +++ b/requirements/partial/requirements_production.txt @@ -4,7 +4,7 @@ dependency_injector==4.41.0 fastjsonschema==2.19.0 gunicorn==21.2.0 lxml==4.9.3 -pypdf[crypto]==3.17.1 +pypdf[crypto]==3.17.2 requests==2.31.0 roman==4.1 simplejson==3.19.2 diff --git a/tests/system/action/meeting/test_clone.py b/tests/system/action/meeting/test_clone.py index 5497366ca9..da258c656a 100644 --- a/tests/system/action/meeting/test_clone.py +++ b/tests/system/action/meeting/test_clone.py @@ -1693,16 +1693,15 @@ def test_with_action_worker(self) -> None: def test_with_import_preview(self) -> None: """import_preview shouldn't be cloned""" - aw_name = "test import_preview" self.test_models["import_preview/1"] = { - "name": aw_name, + "name": "topic", "state": "done", "created": round(time() - 3), } self.set_models(self.test_models) response = self.request("meeting.clone", {"meeting_id": 1}) self.assert_status_code(response, 200) - self.assert_model_exists("import_preview/1", {"name": aw_name}) + self.assert_model_exists("import_preview/1", {"name": "topic"}) self.assert_model_not_exists("import_preview/2") def test_clone_with_2_existing_meetings(self) -> None: diff --git a/tests/system/action/motion/test_create_sequential_number.py b/tests/system/action/motion/test_create_sequential_number.py index 42a925fb14..aa9e9a8b9a 100644 --- a/tests/system/action/motion/test_create_sequential_number.py +++ b/tests/system/action/motion/test_create_sequential_number.py @@ -1,8 +1,6 @@ import threading from typing import Optional -import pytest - from tests.system.action.base import ACTION_URL, BaseActionTestCase from tests.system.action.lock import ( monkeypatch_datastore_adapter_write, @@ -147,9 +145,6 @@ def test_create_sequential_numbers_deleted_motion(self) -> None: model = self.get_model("motion/2") self.assertEqual(model.get("sequential_number"), 2) - @pytest.mark.skip( - reason="Not working with watch-thread, because the testlock is unknown in action_worker" - ) def test_create_sequential_numbers_race_condition(self) -> None: """ !!!We could delete this test or implement a switch-off for the action_worker procedure at all!!! @@ -162,6 +157,7 @@ def test_create_sequential_numbers_race_condition(self) -> None: The lock-object will be shared in threading.local(), instance created in lock.py. If possible you should pass as an argument to the thread function(s). """ + self.set_thread_watch_timeout(-2) pytest_thread_local.name = "MainThread_RC" self.set_models( { diff --git a/tests/system/presenter/test_check_database_all.py b/tests/system/presenter/test_check_database_all.py index 96a27c8fad..ca3fdf4e76 100644 --- a/tests/system/presenter/test_check_database_all.py +++ b/tests/system/presenter/test_check_database_all.py @@ -261,7 +261,7 @@ def test_correct(self) -> None: "timestamp": round(time()), }, "import_preview/1": { - "name": "testcase", + "name": "topic", "state": "done", "created": round(time() - 3), }, diff --git a/tests/system/presenter/test_export_meeting.py b/tests/system/presenter/test_export_meeting.py index f221f9a905..0a6dda2b60 100644 --- a/tests/system/presenter/test_export_meeting.py +++ b/tests/system/presenter/test_export_meeting.py @@ -86,7 +86,7 @@ def test_action_worker_import_preview_exclusion(self) -> None: }, "import_preview/1": { "id": 1, - "name": "testcase", + "name": "topic", "state": "done", "created": round(time()), },