Re: [protobuf] Re: Awkward error. How can this be?

2013-03-22 Thread Oliver Jowett
Let me rephrase: type(message) in handleHeartbeat() is ListType, not
StringType as you are expecting.
See the zmq docs I referred to - your callback receives a multipart list,
not just a single blob of data.

Oliver

On Fri, Mar 22, 2013 at 4:09 PM, Hielke Kramer  wrote:

> No, my callback is given a protobuf serialized message. Exactly the same
> as was sent in the first place.
>
> To explain a bit more: I've got earth and heaven. Earth sends heartbeats
> and heaven responds back. If no message has been received on either side
> for more than two seconds both ends start another task while earth keeps
> sending messages hoping for heaven to come back. The codes are as follows:
>
> earth.py: http://pastebin.com/tvvSZeNR
> heaven.py: http://pastebin.com/rtzCsuvg
> link to errors: http://pastebin.com/jX4SFapt
> compiled protobuf message encoder in python:
> http://www.hkramer.nl/opslag/infoPack_pb2.py
>
> Do you understand any of this?
>
>
>
> 2013/3/22 Oliver Jowett 
>
>> On Fri, Mar 22, 2013 at 8:45 AM, kramer65  wrote:
>>
>>> I've been tinkering about this all night, but with a fresh view in the
>>> morning I still can' t understand what is wrong here. The line where the
>>> error originates is this: beat.ParseFromString(message)
>>>
>>
>> Are you sure your callback is being given a string?
>>
>> From a quick look at
>> http://zeromq.github.com/pyzmq/api/generated/zmq.eventloop.zmqstream.html,
>> it says "callback must take exactly one argument, which will be a list, as
>> returned by socket.recv_multipart()" - i.e. not just a simple string.
>>
>> Oliver
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [protobuf] Re: Awkward error. How can this be?

2013-03-22 Thread Hielke Kramer
No, my callback is given a protobuf serialized message. Exactly the same as
was sent in the first place.

To explain a bit more: I've got earth and heaven. Earth sends heartbeats
and heaven responds back. If no message has been received on either side
for more than two seconds both ends start another task while earth keeps
sending messages hoping for heaven to come back. The codes are as follows:

earth.py: http://pastebin.com/tvvSZeNR
heaven.py: http://pastebin.com/rtzCsuvg
link to errors: http://pastebin.com/jX4SFapt
compiled protobuf message encoder in python:
http://www.hkramer.nl/opslag/infoPack_pb2.py

Do you understand any of this?


2013/3/22 Oliver Jowett 

> On Fri, Mar 22, 2013 at 8:45 AM, kramer65  wrote:
>
>> I've been tinkering about this all night, but with a fresh view in the
>> morning I still can' t understand what is wrong here. The line where the
>> error originates is this: beat.ParseFromString(message)
>>
>
> Are you sure your callback is being given a string?
>
> From a quick look at
> http://zeromq.github.com/pyzmq/api/generated/zmq.eventloop.zmqstream.html,
> it says "callback must take exactly one argument, which will be a list, as
> returned by socket.recv_multipart()" - i.e. not just a simple string.
>
> Oliver
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [protobuf] Re: Awkward error. How can this be?

2013-03-22 Thread Oliver Jowett
On Fri, Mar 22, 2013 at 8:45 AM, kramer65  wrote:

> I've been tinkering about this all night, but with a fresh view in the
> morning I still can' t understand what is wrong here. The line where the
> error originates is this: beat.ParseFromString(message)
>

Are you sure your callback is being given a string?

>From a quick look at
http://zeromq.github.com/pyzmq/api/generated/zmq.eventloop.zmqstream.html,
it says "callback must take exactly one argument, which will be a list, as
returned by socket.recv_multipart()" - i.e. not just a simple string.

Oliver

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[protobuf] Re: Awkward error. How can this be?

2013-03-22 Thread kramer65
I've been tinkering about this all night, but with a fresh view in the 
morning I still can' t understand what is wrong here. The line where the 
error originates is this: beat.ParseFromString(message)

This is the *exact* same line which I use on the other end to parse the 
message. I googled the error (*"expected a character, but string of length 
2 found*") and it seems to have something to do with unicode strings. But I 
don't make use of unicode at all.

I start wondering if zeromq does something wrong but I couldn't imagine 
what. I tested the code with just sending a string ('beat') and that worked 
fine. The error only occured from the moment I used protobuf serialization.

Here is the code on pastebin with the error on line 54: 
http://pastebin.com/aJLCn7TM

Any help?



Op vrijdag 22 maart 2013 01:37:16 UTC+1 schreef kramer65 het volgende:
>
> Hello,
>
> I am doing some tests with protobuf and I run into a strange error. I 
> serialize a message (just one int32) which I send as a heartbeat via 
> zeromq. When it is received on the other end I can parse it and print it. 
> If I send the exact same message back (either the unpacked message or the 
> same int repacked) I get an error while parsing it back in the first 
> script. The strange thing is that it first succeeds to parse, but after 
> sending it back it gives the error below.
>
> Would anybody know whats wrong here? All tips are welcome!
>
>
> ERROR:root:Uncaught exception, closing connection.
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 414, in _run_callback
> callback(*args, **kwargs)
>   File "heartBeat.py", line 56, in handleHeartBeat
> beat.ParseFromString(message)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/message.py",
>  
> line 179, in ParseFromString
> self.MergeFromString(serialized)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 755, in MergeFromString
> if self._InternalParse(serialized, 0, length) != length:
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 774, in InternalParse
> (tag_bytes, new_pos) = local_ReadTag(buffer, pos)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/decoder.py",
>  
> line 172, in ReadTag
> while ord(buffer[pos]) & 0x80:
> TypeError: ord() expected a character, but string of length 2 found
> ERROR:root:Uncaught exception, closing connection.
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 440, in _handle_events
> self._handle_recv()
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 472, in _handle_recv
> self._run_callback(callback, msg)
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 414, in _run_callback
> callback(*args, **kwargs)
>   File "heartBeat.py", line 56, in handleHeartBeat
> beat.ParseFromString(message)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/message.py",
>  
> line 179, in ParseFromString
> self.MergeFromString(serialized)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 755, in MergeFromString
> if self._InternalParse(serialized, 0, length) != length:
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 774, in InternalParse
> (tag_bytes, new_pos) = local_ReadTag(buffer, pos)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/decoder.py",
>  
> line 172, in ReadTag
> while ord(buffer[pos]) & 0x80:
> TypeError: ord() expected a character, but string of length 2 found
> ERROR:root:Exception in I/O handler for fd  at 0x9bfd23c>
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/ioloop.py",
>  
> line 346, in start
> self._handlers[fd](fd, events)
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 440, in _handle_events
> self._handle_recv()
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 472, in _handle_recv
> self._run_callback(callback, msg)
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line