Fixes: 1) Update worker entrypoints to adjust prefetch multiplier and memory/task limits for optimized resource usage. Extra: 1) Refactor Celery settings into a dedicated file for improved organization and maintainability; 2) Adjust Docker entrypoints to align with updated task configurations; 3) Register `orjson` serializer in a separate module for cleaner code structure.
22 lines
461 B
Python
22 lines
461 B
Python
import orjson
|
|
from kombu.serialization import register
|
|
|
|
|
|
def orjson_dumps(obj):
|
|
return orjson.dumps(obj, option=orjson.OPT_NON_STR_KEYS).decode("utf-8")
|
|
|
|
|
|
def orjson_loads(data):
|
|
if isinstance(data, str):
|
|
data = data.encode("utf-8")
|
|
return orjson.loads(data)
|
|
|
|
|
|
def register_orjson():
|
|
register(
|
|
"orjson",
|
|
orjson_dumps,
|
|
orjson_loads,
|
|
content_type="application/json",
|
|
content_encoding="utf-8",
|
|
)
|