Skip to content

Commit

Permalink
kombu encode/decode -> .dumps/.loads
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Sep 24, 2013
1 parent f6bef02 commit 5d46c32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions celery/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from billiard.einfo import ExceptionInfo
from kombu.serialization import (
encode, decode, prepare_accept_content,
dumps, loads, prepare_accept_content,
registry as serializer_registry,
)
from kombu.utils.encoding import bytes_to_str, ensure_bytes, from_utf8
Expand Down Expand Up @@ -138,15 +138,15 @@ def prepare_value(self, result):
return result

def encode(self, data):
_, _, payload = encode(data, serializer=self.serializer)
_, _, payload = dumps(data, serializer=self.serializer)
return payload

def decode(self, payload):
payload = PY3 and payload or str(payload)
return decode(payload,
content_type=self.content_type,
content_encoding=self.content_encoding,
accept=self.accept)
return loads(payload,
content_type=self.content_type,
content_encoding=self.content_encoding,
accept=self.accept)

def wait_for(self, task_id, timeout=None, propagate=True, interval=0.5):
"""Wait for task and return its result.
Expand Down
8 changes: 4 additions & 4 deletions celery/security/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import base64

from kombu.serialization import registry, encode, decode
from kombu.serialization import registry, dumps, loads
from kombu.utils.encoding import bytes_to_str, str_to_bytes, ensure_bytes

from .certificate import Certificate, FSCertStore
Expand Down Expand Up @@ -43,7 +43,7 @@ def serialize(self, data):
assert self._key is not None
assert self._cert is not None
with reraise_errors('Unable to serialize: {0!r}', (Exception, )):
content_type, content_encoding, body = encode(
content_type, content_encoding, body = dumps(
data, serializer=self._serializer)
# What we sign is the serialized body, not the body itself.
# this way the receiver doesn't have to decode the contents
Expand All @@ -63,8 +63,8 @@ def deserialize(self, data):
payload['signer'],
payload['body'])
self._cert_store[signer].verify(body, signature, self._digest)
return decode(bytes_to_str(body), payload['content_type'],
payload['content_encoding'], force=True)
return loads(bytes_to_str(body), payload['content_type'],
payload['content_encoding'], force=True)

def _pack(self, body, content_type, content_encoding, signer, signature,
sep=str_to_bytes('\x00\x01')):
Expand Down

0 comments on commit 5d46c32

Please sign in to comment.