Jay Taylor's notes
back to listing indexProtocol buffers python - unicode decode error
[web search]
I need to receive a protocol buffers message on my python - tornado server and get the stuff out of the binary message.
It works perfectly using a test tool. When i run it in sandbox environment and simulate 1000 requests from my client, it works in certain cases, but in most of the requests, it throws an exception -
In some other cases it gives these errors -
What could be the reason ? |
|||||||||||||||||||||
|
|||||||||||||||||||||
I had exactly same problem with RabbitMQ and Protocol Buffers. The problem is that protocol buffer assumes the input to be of type str, whereas RabbitMQ seems to decode the message as unicode in some cases (if the byte array contains bytes greater than 127). The same may happen with Tornado as well. So far it seems, that the problem can be solved by following piece of code:
This code turns the unicode string to python bytes object, which can be happily parsed by protocol buffer messages. Dunno if there is some better way to do this, but at least this seems to work. |
|||||||||||||||
|
Your Answer
Not the answer you're looking for? Browse other questions tagged python unicode utf-8 protocol-buffers or ask your own question.
asked |
4 years ago |
viewed |
3629 times |
active |
Related
Hot Network Questions
- Explosives in the Middle Ages
- Is it worth colonizing a planet that travels near the speed of light?
- How is it possible for a hotel to have Wifi but no internet access?
- Solder new RAM in a 2015 Retina MacBook Pro
- Rube Goldberg Hello World
- How do you protect Ubuntu login?
- Referee report ignored and not sent to authors
- What is Ptolemy holding in his picture on Wikipedia?
- How to increase readability of code?
- What can I do about an ex-landlord “trash talking” me on Facebook?
- Math without pencil and paper
- Count Up, Replace, Repeat!
- Why do thin films need to be thin?
- Convert YYYYMM to MMMYY
- Why we use the term "scalar" and not the common term "number" in Linear Algebra?
- What are the implications of converting all my groups to universal groups?
- Center alignment with multirow package
- I cosigned for a friend who is not paying the payment
- Can I ignore multicolinearity problem if all the regression coefficients are highly significant?
- How to select elements from a list of pairs based on 2nd element of the pair
- How to debug the C code for LibraryLink?
- RegionIntersection puzzle
- Dump the output of internal vim command into buffer
- What should I do about Gmail ad asking me for password?
Technology | Life / Arts | Culture / Recreation | Science | Other | ||
---|---|---|---|---|---|---|