#1539 Gevent breaks PyUnit test runner

open
Editor (491)
5
2012-10-21
2012-10-21
Mihai L
No

Patching sockets with Gevent's monkey.patch_socket() or monkey.patch_all(socket=True) raises "NotImplementedError: gevent is only usable from a single thread" everytime. PyUnit doesn't display anything in this case.

Sample in gevent_test.py attached. Running this sample in Eclipse Juno (20120920-0800) / PyDev 2.7.1. 2012100913 / Ubuntu 64b produces the following output:

"
Finding files... done.
Importing test modules ... done.

Started TestA.testInitA()
<test.tmp.gevent_test.A object at 0xda8610>
Ended TestA.testInitA()
----------------------------------------------------------------------
Ran 1 test in 0.020s

OK
Traceback (most recent call last):
File "/home/xxx/work/eclipse/plugins/org.python.pydev_2.7.1.2012100913/pysrc/pydev_runfiles_xml_rpc.py", line 131, in run
self.server.notifyCommands(commands)
File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1292, in single_request
self.send_content(h, request_body)
File "/usr/lib/python2.7/xmlrpclib.py", line 1439, in send_content
connection.endheaders(request_body)
File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 814, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 776, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 757, in connect
self.timeout, self.source_address)
File "/home/xxx/.virtualenvs/Env.yyy/local/lib/python2.7/site-packages/gevent/socket.py", line 646, in create_connection
sock.connect(sa)
File "/home/xxx/.virtualenvs/Env.yyy/local/lib/python2.7/site-packages/gevent/socket.py", line 376, in connect
wait_readwrite(sock.fileno(), event=self._rw_event)
File "/home/xxx/.virtualenvs/Env.yyy/local/lib/python2.7/site-packages/gevent/socket.py", line 215, in wait_readwrite
switch_result = get_hub().switch()
File "/home/xxx/.virtualenvs/Env.yyy/local/lib/python2.7/site-packages/gevent/hub.py", line 135, in get_hub
raise NotImplementedError('gevent is only usable from a single thread')
NotImplementedError: gevent is only usable from a single thread
"

Discussion

  • Mihai L
    Mihai L
    2012-10-21

     
    Attachments