Skip to content

Commit

Permalink
Merge branch 'main' into I2049_mediafile_mimetypes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsangmeister authored Dec 12, 2023
2 parents 870fb2e + 4aa1f48 commit b2e9378
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions global/meta/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3846,6 +3846,10 @@ import_preview:
name:
type: string
required: true
enum:
- account
- participant
- topic
restriction_mode: A
state:
type: string
Expand Down
7 changes: 6 additions & 1 deletion openslides_backend/action/action_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ 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
action_worker_thread.start()
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"):
Expand Down
6 changes: 4 additions & 2 deletions openslides_backend/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"]}
)
Expand Down
2 changes: 1 addition & 1 deletion requirements/partial/requirements_development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements/partial/requirements_production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions tests/system/action/meeting/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions tests/system/action/motion/test_create_sequential_number.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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!!!
Expand 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(
{
Expand Down
2 changes: 1 addition & 1 deletion tests/system/presenter/test_check_database_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
Expand Down
2 changes: 1 addition & 1 deletion tests/system/presenter/test_export_meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
},
Expand Down

0 comments on commit b2e9378

Please sign in to comment.