Skip to content

Commit

Permalink
Change column type for Extended Task Meta args/kwargs
Browse files Browse the repository at this point in the history
SQLite3 database driver requires unicode strings.

Column type changed to Binary instead of Text https://docs.sqlalchemy.org/en/13/core/type_basics.html#sqlalchemy.types.LargeBinary
  • Loading branch information
georgepsarakis authored and auvipy committed May 26, 2019
1 parent 689ca4f commit 8d77fc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions celery/backends/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from vine.utils import wraps

from kombu.utils.encoding import ensure_bytes

from celery import states
from celery.backends.base import BaseBackend
from celery.exceptions import ImproperlyConfigured
Expand Down Expand Up @@ -134,8 +136,12 @@ def _update_result(self, task, result, state, traceback=None,
task.traceback = traceback
if self.app.conf.find_value_for_key('extended', 'result'):
task.name = getattr(request, 'task_name', None)
task.args = self.encode(getattr(request, 'args', None))
task.kwargs = self.encode(getattr(request, 'kwargs', None))
task.args = ensure_bytes(
self.encode(getattr(request, 'args', None))
)
task.kwargs = ensure_bytes(
self.encode(getattr(request, 'kwargs', None))
)
task.worker = getattr(request, 'hostname', None)
task.retries = getattr(request, 'retries', None)
task.queue = (
Expand Down
4 changes: 2 additions & 2 deletions celery/backends/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class TaskExtended(Task):
__table_args__ = {'sqlite_autoincrement': True, 'extend_existing': True}

name = sa.Column(sa.String(155), nullable=True)
args = sa.Column(sa.Text, nullable=True)
kwargs = sa.Column(sa.Text, nullable=True)
args = sa.Column(sa.LargeBinary, nullable=True)
kwargs = sa.Column(sa.LargeBinary, nullable=True)
worker = sa.Column(sa.String(155), nullable=True)
retries = sa.Column(sa.Integer, nullable=True)
queue = sa.Column(sa.String(155), nullable=True)
Expand Down

0 comments on commit 8d77fc9

Please sign in to comment.