karrio-server 2025.5rc28__py3-none-any.whl → 2025.5rc29__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.5rc29
@@ -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,50 @@ 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(
272
+ "WORKER_IMMEDIATE_MODE", default=(_REDIS_HOST is None), cast=bool
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
+ "immediate": _WORKER_IMMEDIATE_MODE,
281
+ "utc": True,
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
+ "username": _REDIS_USERNAME,
293
+ "password": _REDIS_PASSWORD,
294
+ } if _REDIS_PASSWORD else {}),
295
+ },
296
+ } if _REDIS_HOST else {}),
297
+ **({
298
+ "filename": os.path.join(WORK_DIR, "tasks.sqlite3"),
299
+ } if not _REDIS_HOST else {}),
300
+ }
301
+
302
+ # Karrio Server Background jobs interval config
303
+ DEFAULT_SCHEDULER_RUN_INTERVAL = 3600 # value is seconds. so 3600 seconds = 1 Hour
304
+ DEFAULT_TRACKERS_UPDATE_INTERVAL = config(
305
+ "TRACKING_PULSE", default=7200, cast=int
306
+ ) # value is seconds. so 10800 seconds = 3 Hours
307
+
264
308
  INSTALLED_APPS = [
265
309
  "constance",
266
310
  *KARRIO_APPS,
@@ -352,6 +396,15 @@ if config("DATABASE_URL", default=None):
352
396
  )
353
397
  DATABASES["default"].update(db_from_env)
354
398
 
399
+ # Configure workers database for SQLite storage when Redis is not available
400
+ if not config("REDIS_HOST", default=None):
401
+ _WORKER_DB_DIR = config("WORKER_DB_DIR", default=WORK_DIR)
402
+ _WORKER_DB_FILE_NAME = os.path.join(_WORKER_DB_DIR, "tasks.sqlite3")
403
+ DATABASES["workers"] = {
404
+ "NAME": _WORKER_DB_FILE_NAME,
405
+ "ENGINE": "django.db.backends.sqlite3",
406
+ }
407
+
355
408
  # Password validation
356
409
  # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
357
410