Commit bf500dff by Nicolas Wavrant

equeue: use BytesIO instead of StringiO as buffer

as StringIO only accepts unicode, but socket.recv() returns a string
1 parent 099295af
......@@ -157,11 +157,12 @@ class EqueueServer(socketserver.ThreadingUnixStreamServer):
# Handle request
self.logger.debug("Connection with file descriptor %d", request.fileno())
request.settimeout(self.options.timeout)
request_string = io.StringIO()
segment = None
request_string = io.BytesIO()
try:
while segment != '':
while 1:
segment = request.recv(1024)
if not segment:
break
request_string.write(segment)
except socket.timeout:
pass
......
  • This seems fine.

  • This change looks ok, but this code does not seem to be already python 3 compatible.

    I see

        command = '127'
        ... 
        request.send(command)
    

    below, on python 3 that would

    TypeError: a bytes-like object is required, not 'str'
    

    maybe it works on python2

  • As far as I know, there is no unit test for equeue (and most of the resiliency tools) as the resilience tests were deemed to be enough, so I'm not surprised that many details are wrong for the python3 support.

    Is there a test suite running the resilient test suite with all python services using python3 (I don't think it is easy to set up though) ?

    Otherwise we should task someone to write unit tests for at least equeue and pubsub.

    @jm , @bminusl : I'm tagging you because most probably you were not notified by @jerome 's comment.

  • Is there a test suite running the resilient test suite with all python services using python3 (I don't think it is easy to set up though) ?

    not yet, but @luke and I are planning to make software/slapos-sr-testing run tests using python3. This will be a first step, because it would cover using slapos in python3 to install software and create instances. There are a few things not working with promises. We started to fix in slapos.core!146

    Otherwise we should task someone to write unit tests for at least equeue and pubsub.

    It's not for me to decide, but equeue looks like something that we should not write ourselves. There are already existing / maintained packages for task queues. Also I don't know this code, but maybe just running process with a lockfile would have been enough.

  • -      command = str(request_parameters['command'])
    +      command = request_parameters['command']
    
    -      request.send(command)
    +      request.send(command.encode())
    
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!