Reputation: 1397
I am calling tasks in celery with a RabbitMQ broker on an Ubuntu box, but just getting set up using Redis as the result backend. I can find task results, but they look like ""\x80\x02}q\x01(U\x06statusq\x02U\aSUCCESSq\x03U\ttracebackq\x04NU\x06resultq\x05}q\x06(X\x06\x00\x00\x00result}q\a(X\x06\x00\x00\x00statusK\x01X\r\x00\x00\x00total_resultsM\xf4\x01X\a\x00\x00\x00matches]q\b(}q\t(X\a\x00\x00\x00players]q\n(}q\x0b(X\a\x00\x00\x00hero_idK\x15X\n\x00\x00\x00account_idI4294967295\nX\x0b\x00\x00\x00player_slotK\x00u}q\x0c(X\a\x00\x00\x00hero_idK\x0cX\n\x00\x00\x00account_idI4294967295\nX\x0b\x00\x00\x00player_slotK\x01u}q\r(X\a\x00\x00\x00hero_idK\x1bX\n\x00\x00\x00account_i...."
My default celery encoding is ASCII, and Redis does not appear to have an encoding specified in its base conf.
utils.encoding.default_encoding()
'ascii'
How should I go about turning this text into something meaningful? I cannot tell how this is encoded on sight; any suggested decodings to try?
Upvotes: 2
Views: 1421
Reputation: 2903
The result is pickled by default into a utf-8 string (see task serializers). You can inspect the payload manually with:
import pickle
s = "\x80\x02}q..."
obj = pickle.loads(s)
print obj
pickle
is generally fine unless you are operating in a polyglot environment, and then JSON or msgpack are fine solutions.
Upvotes: 4