Hi Michael,

>> +  def _Recv(self):

[cut]

> Already much better, but there are two issues:
>
> - What if more than one message is sent? You buffer it locally, but
> the next call to _Recv will be missing that part of the message. You
> need to keep the receive buffer in the instance.
> - If one byte of the end token happens to be at the end of the read
> ("…\r", second read would yield "\n") this doesn't work. You need to
> check if the token is in the buffer (since this is more expensive you
> can also check the temporary variable).

Right, I will rewrite the code taking this into account.

>> +    received_data = recv_buffer.getvalue()
>
> Not sure: assert received_data.endswith(_MESSAGE_END_TOKEN)?

Hmm.. good point, I need to check that but instead of an assert I
would raise a HypervisorError.

>> +           hv_kvm.QmpConnection._MESSAGE_END_TOKEN
>> […]
>> +  def _executeTestScript(self, script):
>> +    # Set up the stub
>> +    socket_filename = self._CreateTempFile()
>> +    os.remove(socket_filename)
>
> Why don't you just use the tempfile module? _CreateTempFile & Co. are painful.

I will use a NamedTemporaryFile, even if I don't see much difference
with _CreateTempFile.

Thanks,
Andrea

Reply via email to