openmodule 18.1.1__tar.gz → 18.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openmodule-18.1.1 → openmodule-18.2.0}/PKG-INFO +1 -1
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/core.py +8 -7
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/database/database.py +6 -6
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/health.py +1 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule.egg-info/PKG-INFO +1 -1
- {openmodule-18.1.1 → openmodule-18.2.0}/LICENSE +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/README.md +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/__init__.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/alert.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/config.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/connection_status.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/database/__init__.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/database/custom_types.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/database/env.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/database/migration.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/dispatcher.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/logging.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/messaging.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/__init__.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/access_service.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/alert.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/base.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/io.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/kv_store.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/pagination.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/presence.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/privacy.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/rpc.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/settings.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/signals.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/validation.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/vehicle.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/models/vehicle_listener.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/rpc/__init__.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/rpc/client.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/rpc/common.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/rpc/server.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/sentry.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/threading.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/__init__.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/access_service.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/charset.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/cleanup.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/csv_export.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/databox.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/db_helper.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/eventlog.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/io.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/kv_store.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/matching.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/misc_functions.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/package_reader.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/pagination.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/presence.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/schedule.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/settings.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/signal_listener.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/translation.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/validation.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule/utils/vehicle_listener.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule.egg-info/SOURCES.txt +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule.egg-info/dependency_links.txt +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule.egg-info/not-zip-safe +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule.egg-info/requires.txt +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/openmodule.egg-info/top_level.txt +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/setup.cfg +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/setup.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_alembic_migrations.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_alert.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_checks.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_config.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_connection_status.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_core.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_database.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_dispatcher.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_health.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_interrupt.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_io_listen.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_logging.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_messaging.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_mockrpcclient.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_model.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_rpc.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_sentry.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_test_alert.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_test_gate.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_test_zeromq.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_access_service.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_charset.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_cleanup.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_csv_export.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_databox.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_eventlog.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_kv_store.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_kv_store_multiple.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_matching.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_misc_functions.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_package_reader.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_pagination.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_presence.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_schedule.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_settings.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_signal.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_validation.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_utils_vehicle.py +0 -0
- {openmodule-18.1.1 → openmodule-18.2.0}/tests/test_vehicle_listener.py +0 -0
|
@@ -55,12 +55,13 @@ class OpenModuleCore(threading.Thread):
|
|
|
55
55
|
self._messages_internal.register_handler("healthz", HealthPingMessage, self.health.process_message,
|
|
56
56
|
match_type=True)
|
|
57
57
|
|
|
58
|
-
def init_database(self):
|
|
58
|
+
def init_database(self, migration_timeout: float = 300):
|
|
59
59
|
from openmodule.database.database import Database
|
|
60
60
|
if self.config.TESTING:
|
|
61
|
-
self.database = Database(self.config.DATABASE_FOLDER, self.config.NAME, alembic_path="../src/database"
|
|
61
|
+
self.database = Database(self.config.DATABASE_FOLDER, self.config.NAME, alembic_path="../src/database",
|
|
62
|
+
migration_timeout=migration_timeout)
|
|
62
63
|
else:
|
|
63
|
-
self.database = Database(self.config.DATABASE_FOLDER, self.config.NAME)
|
|
64
|
+
self.database = Database(self.config.DATABASE_FOLDER, self.config.NAME, migration_timeout=migration_timeout)
|
|
64
65
|
|
|
65
66
|
def start(self) -> None:
|
|
66
67
|
super().start()
|
|
@@ -153,9 +154,9 @@ def wait_for_misc(core: OpenModuleCore, timeout: float = 120, retry_time: float
|
|
|
153
154
|
|
|
154
155
|
|
|
155
156
|
def init_openmodule(config, *, dsn: str = None, sentry=None, logging=True, dsgvo=True,
|
|
156
|
-
health_handler: HealthHandlerType | None = None,
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
health_handler: HealthHandlerType | None = None, context=None, database=False, catch_sigterm=True,
|
|
158
|
+
dispatcher_max_threads=1, wait_for_broker=True, migration_timeout=300.0, **sentry_kwargs) \
|
|
159
|
+
-> OpenModuleCore:
|
|
159
160
|
if health_handler:
|
|
160
161
|
warnings.warn(
|
|
161
162
|
"health_handler is deprecated, and will simply be ignored. Please use metrics "
|
|
@@ -208,7 +209,7 @@ def init_openmodule(config, *, dsn: str = None, sentry=None, logging=True, dsgvo
|
|
|
208
209
|
_core_thread.health.health_handler = health_handler
|
|
209
210
|
|
|
210
211
|
if database:
|
|
211
|
-
_core_thread.init_database()
|
|
212
|
+
_core_thread.init_database(migration_timeout)
|
|
212
213
|
|
|
213
214
|
if catch_sigterm and threading.current_thread().__class__.__name__ == "_MainThread":
|
|
214
215
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
|
@@ -47,7 +47,7 @@ def set_sqlite_pragma(dbapi_connection, connection_record):
|
|
|
47
47
|
active_databases = {}
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def execute_migration(engine: Engine, alembic_path: Optional[str] = None):
|
|
50
|
+
def execute_migration(engine: Engine, alembic_path: Optional[str] = None, migration_timeout: float = 300):
|
|
51
51
|
def isolated_migration_process():
|
|
52
52
|
nonlocal engine, alembic_path
|
|
53
53
|
from openmodule.database.migration import migrate_database
|
|
@@ -56,7 +56,7 @@ def execute_migration(engine: Engine, alembic_path: Optional[str] = None):
|
|
|
56
56
|
p = MigrationProcess(target=isolated_migration_process)
|
|
57
57
|
try:
|
|
58
58
|
p.start()
|
|
59
|
-
p.join(timeout=
|
|
59
|
+
p.join(timeout=migration_timeout) # default 5 min timeout -> exception/sentry in service
|
|
60
60
|
except ProcessError:
|
|
61
61
|
raise
|
|
62
62
|
finally:
|
|
@@ -78,7 +78,7 @@ def database_path(db_folder, db_name):
|
|
|
78
78
|
return os.path.join(db_folder, db_name) + ".sqlite3"
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
def get_database(db_folder: str, name: str, alembic_path: Optional[str] = None):
|
|
81
|
+
def get_database(db_folder: str, name: str, alembic_path: Optional[str] = None, migration_timeout: float = 300):
|
|
82
82
|
global active_databases
|
|
83
83
|
tmp = database_path(db_folder, name)
|
|
84
84
|
assert active_databases.get(tmp) is None, f"database {tmp} already exists," \
|
|
@@ -88,7 +88,7 @@ def get_database(db_folder: str, name: str, alembic_path: Optional[str] = None):
|
|
|
88
88
|
engine = create_engine(path, poolclass=StaticPool, connect_args={'check_same_thread': False})
|
|
89
89
|
|
|
90
90
|
# migration executed in a separate process -> no alembic import in main process
|
|
91
|
-
execute_migration(engine, alembic_path)
|
|
91
|
+
execute_migration(engine, alembic_path, migration_timeout)
|
|
92
92
|
|
|
93
93
|
active_databases[tmp] = engine
|
|
94
94
|
|
|
@@ -124,10 +124,10 @@ class SessionWrapper(Session):
|
|
|
124
124
|
class Database:
|
|
125
125
|
active_session: Optional[Session]
|
|
126
126
|
|
|
127
|
-
def __init__(self, database_folder, name="database", alembic_path=None):
|
|
127
|
+
def __init__(self, database_folder, name="database", alembic_path=None, migration_timeout: float = 300):
|
|
128
128
|
self.db_folder = database_folder
|
|
129
129
|
self.name = name
|
|
130
|
-
self._engine = get_database(database_folder, name, alembic_path)
|
|
130
|
+
self._engine = get_database(database_folder, name, alembic_path, migration_timeout)
|
|
131
131
|
self._session = sessionmaker(bind=self._engine, class_=SessionWrapper)
|
|
132
132
|
self.active_session = None
|
|
133
133
|
self.lock = threading.RLock()
|
|
@@ -249,6 +249,7 @@ class Healthz:
|
|
|
249
249
|
metric = self.metrics.get(key)
|
|
250
250
|
if not metric:
|
|
251
251
|
self._metric_log_or_raise("Metric %s not found, the metric will not be set", key)
|
|
252
|
+
return
|
|
252
253
|
if value is None:
|
|
253
254
|
metric.values.pop(self._labels_string(labels), None)
|
|
254
255
|
elif metric.type == HealthMetricType.count:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|