karrio-server 2025.5rc28__py3-none-any.whl → 2025.5rc30__py3-none-any.whl

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.
karrio/server/VERSION CHANGED
@@ -1 +1 @@
1
- 2025.5rc28
1
+ 2025.5rc30
@@ -5,7 +5,6 @@ import importlib.util
5
5
  from karrio.server.settings.base import *
6
6
  from karrio.server.settings.apm import *
7
7
  from karrio.server.settings.cache import *
8
- from karrio.server.settings.workers import *
9
8
  from karrio.server.settings.debug import *
10
9
  from karrio.server.settings.email import *
11
10
  from karrio.server.settings.constance import *
@@ -169,15 +169,18 @@ if OTEL_ENABLED and OTEL_EXPORTER_OTLP_ENDPOINT:
169
169
  RedisInstrumentor().instrument()
170
170
  except Exception:
171
171
  pass # Redis might not be installed
172
-
173
- # Instrument Huey task queue (temporarily disabled due to compatibility issues)
174
- # try:
175
- # from karrio.server.lib.otel_huey import instrument_huey
176
- # instrument_huey()
177
- # except Exception as e:
178
- # logger = logging.getLogger(__name__)
179
- # logger.warning(f"Failed to instrument Huey: {e}")
180
-
172
+
173
+ # Instrument Huey task queue
174
+ try:
175
+ from huey.contrib.djhuey import HUEY as huey_instance
176
+ from karrio.server.lib.otel_huey import HueyInstrumentor
177
+
178
+ instrumentor = HueyInstrumentor()
179
+ instrumentor.instrument(huey_instance)
180
+ except Exception as e:
181
+ logger = logging.getLogger(__name__)
182
+ logger.warning(f"Failed to instrument Huey: {e}")
183
+
181
184
  # Log that OpenTelemetry is enabled
182
185
  logger = logging.getLogger(__name__)
183
186
  logger.info(f"OpenTelemetry enabled: Service={OTEL_SERVICE_NAME}, Endpoint={OTEL_EXPORTER_OTLP_ENDPOINT}")
@@ -261,6 +261,62 @@ OTP_APPS = [
261
261
  "two_factor.plugins.email",
262
262
  ]
263
263
 
264
+ # Configure HUEY before djhuey/apps are loaded
265
+ # This must be done here (not in workers.py) because task modules import djhuey
266
+ # at module load time, which happens when Django loads apps from INSTALLED_APPS
267
+ _REDIS_HOST = config("REDIS_HOST", default=None)
268
+ _REDIS_PORT = config("REDIS_PORT", default=None)
269
+ _REDIS_PASSWORD = config("REDIS_PASSWORD", default=None)
270
+ _REDIS_USERNAME = config("REDIS_USERNAME", default="default")
271
+ _WORKER_IMMEDIATE_MODE = config("WORKER_IMMEDIATE_MODE", default=False, cast=bool) and (
272
+ _REDIS_HOST is None
273
+ )
274
+
275
+ HUEY = {
276
+ "huey_class": "huey.RedisHuey" if _REDIS_HOST else "huey.SqliteHuey",
277
+ "name": "default",
278
+ "results": True,
279
+ "store_none": False,
280
+ "utc": True,
281
+ **(
282
+ {
283
+ "blocking": True,
284
+ "connection": {
285
+ "host": _REDIS_HOST,
286
+ "port": _REDIS_PORT or 6379,
287
+ "db": 0,
288
+ "connection_pool": None,
289
+ "read_timeout": 1,
290
+ "max_connections": 20,
291
+ **(
292
+ {
293
+ "username": _REDIS_USERNAME,
294
+ "password": _REDIS_PASSWORD,
295
+ }
296
+ if _REDIS_PASSWORD
297
+ else {}
298
+ ),
299
+ },
300
+ }
301
+ if _REDIS_HOST
302
+ else {}
303
+ ),
304
+ **(
305
+ {
306
+ "filename": os.path.join(WORK_DIR, "tasks.sqlite3"),
307
+ "immediate": _WORKER_IMMEDIATE_MODE,
308
+ }
309
+ if not _REDIS_HOST
310
+ else {}
311
+ ),
312
+ }
313
+
314
+ # Karrio Server Background jobs interval config
315
+ DEFAULT_SCHEDULER_RUN_INTERVAL = 3600 # value is seconds. so 3600 seconds = 1 Hour
316
+ DEFAULT_TRACKERS_UPDATE_INTERVAL = config(
317
+ "TRACKING_PULSE", default=7200, cast=int
318
+ ) # value is seconds. so 10800 seconds = 3 Hours
319
+
264
320
  INSTALLED_APPS = [
265
321
  "constance",
266
322
  *KARRIO_APPS,
@@ -352,6 +408,15 @@ if config("DATABASE_URL", default=None):
352
408
  )
353
409
  DATABASES["default"].update(db_from_env)
354
410
 
411
+ # Configure workers database for SQLite storage when Redis is not available
412
+ if not config("REDIS_HOST", default=None):
413
+ _WORKER_DB_DIR = config("WORKER_DB_DIR", default=WORK_DIR)
414
+ _WORKER_DB_FILE_NAME = os.path.join(_WORKER_DB_DIR, "tasks.sqlite3")
415
+ DATABASES["workers"] = {
416
+ "NAME": _WORKER_DB_FILE_NAME,
417
+ "ENGINE": "django.db.backends.sqlite3",
418
+ }
419
+
355
420
  # Password validation
356
421
  # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
357
422