|
@@ -17,6 +17,7 @@ from celery.registry import tasks
|
|
from celery.utils import noop, kwdict, fun_takes_kwargs
|
|
from celery.utils import noop, kwdict, fun_takes_kwargs
|
|
from celery.utils import truncate_text
|
|
from celery.utils import truncate_text
|
|
from celery.utils.compat import log_with_extra
|
|
from celery.utils.compat import log_with_extra
|
|
|
|
+from celery.utils.encoding import safe_str
|
|
from celery.utils.timeutils import maybe_iso8601
|
|
from celery.utils.timeutils import maybe_iso8601
|
|
from celery.worker import state
|
|
from celery.worker import state
|
|
|
|
|
|
@@ -55,22 +56,6 @@ class AlreadyExecutedError(Exception):
|
|
world-wide state."""
|
|
world-wide state."""
|
|
|
|
|
|
|
|
|
|
-def default_encoding():
|
|
|
|
- if sys.platform.startswith("java"):
|
|
|
|
- return "utf-8"
|
|
|
|
- return sys.getfilesystemencoding()
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-def safe_str(s, errors="replace"):
|
|
|
|
- encoding = default_encoding()
|
|
|
|
- try:
|
|
|
|
- if isinstance(s, unicode):
|
|
|
|
- return s.encode(encoding, errors)
|
|
|
|
- return unicode(s, encoding, errors)
|
|
|
|
- except Exception:
|
|
|
|
- return "<Unrepresentable %r>" % (type(s), )
|
|
|
|
-
|
|
|
|
-
|
|
|
|
class WorkerTaskTrace(TaskTrace):
|
|
class WorkerTaskTrace(TaskTrace):
|
|
"""Wraps the task in a jail, catches all exceptions, and
|
|
"""Wraps the task in a jail, catches all exceptions, and
|
|
saves the status and result of the task execution to the task
|
|
saves the status and result of the task execution to the task
|