I have this code:
...
msgdict = {'datafile': datafile, 'mapper': mapper, 'reducer':reducer}
msg = cPickle.dumps(msgdict)
print msg   
The print msg I get this:
(dp1
S'mapper'
p2
(S's3n://myFolder/mapper.py'
p3
tp4
sS'datafile'
p5
(S's3n://myFolder/test.txt'
p6
tp7
sS'reducer'
p8
(S's3n://myFolder/reducer.py'
p9
tp10
s.
Then Im trying to get my content:
for i in range(count):
    m = q[0].read()
    # this print returns a object Message
    print m 
    # m.get_body()) returns the same of print msg above
    msg = cPickle.loads(m.get_body()) 
But Im having this errror:
msg = cPickle.loads(m.get_body())       
TypeError: must be string, not unicode
Someone knows how to solve this error?
Try to replace that line with the following:
msg = cPickle.loads(str(m.get_body()))
By casting str() to m.get_body(), it makes sure that if the string is unicode, it converts it to a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With