Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Unix socket tests failing on RHEL5, Python 2.7 #12

Open
hoffman opened this Issue · 4 comments

4 participants

@hoffman
$ uname -srv
Linux 2.6.18-238.1.1.el5 #1 SMP Tue Jan 4 13:32:19 EST 2011

$ python -V
Python 2.7

$ python tests.py
===============================================================
  NOTE: There may be threading exceptions after tests finish.  
===============================================================
....................EEEEEEEE
======================================================================
ERROR: test_connect (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 279, in test_connect
    result = client.ping()
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 276, in __call__
    return self.__send(self.__name, kwargs)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_multicall_failure (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 341, in test_multicall_failure
    result = multicall()
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 362, in _request
    responses = self._server._run_request(request_body)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_multicall_success (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 333, in test_multicall_success
    result = multicall()
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 362, in _request
    responses = self._server._run_request(request_body)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_args (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 284, in test_single_args
    result = client.add(5, 10)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_kwargs (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 289, in test_single_kwargs
    result = client.add(x=5, y=10)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 276, in __call__
    return self.__send(self.__name, kwargs)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_kwargs_and_args (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 294, in test_single_kwargs_and_args
    self.assertRaises(ProtocolError, client.add, (5,), {'y':10})
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/unittest/case.py", line 456, in assertRaises
    callableObj(*args, **kwargs)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_namespace (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 303, in test_single_namespace
    response = client.namespace.sum(1,2,4)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_notify (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 298, in test_single_notify
    result = client._notify.add(5, 10)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 231, in _request_notify
    response = self._run_request(request, notify=True)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

----------------------------------------------------------------------
Ran 28 tests in 0.124s

FAILED (errors=8)
@lzyy

the same happened in OSX with python 2.7

@chozabu

Wow, same thing is happening to me two years later

@jkolczasty

Bug exists for 3 years and permanently ignored by author. Nice.

@jkolczasty

Fix for the client side:

class UnixHTTPConnection(httplib.HTTPConnection):
    def connect(self):
        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        if isinstance(self.timeout, object):
            timeout = 30
        else:
            timeout = self.timeout

        sock.settimeout(timeout)
        sock.connect(self.host)
        self.sock = sock
        return sock


class UnixTransport(jsonrpclib.jsonrpc.TransportMixIn, jsonrpclib.jsonrpc.XMLTransport):
    _connection = None

    def make_connection(self, host):
        host, self._extra_headers, x509 = self.get_host_info(host)
        self._connection = host, UnixHTTPConnection(host)
        return self._connection[1]

Usage:

s = jsonrpclib.Server('unix:.test1.sock', transport=UnixTransport())

Even after fixing client side, there is still problem on server side:

  File "/usr/lib64/python2.7/SocketServer.py", line 698, in setup
    socket.TCP_NODELAY, True)
...
error: [Errno 95] Operation not supported

Used StreamRequestHandler in SocketServer tries to set TCP_NODELAY by default, which is not supported on unix sockets. Unfortunately whole jsonrpclib is based on python xmlrpclib, so fixing this issue is not so simple as the client side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.