dvdotsenko / nose_gevent_multiprocess

Gevent-supporting multiprocess plugin for Nose testing framework
GNU Lesser General Public License v2.1
13 stars 8 forks source link

'TypeError: __import__() argument 1 must be string without null bytes, not str' from clients on startup #1

Open kacarstensen-shift opened 10 years ago

kacarstensen-shift commented 10 years ago

Full traceback (repeated once for each client process):

Traceback (most recent call last):
  File "/Users/kacarstensen/Documents/work/shift-virtualenv/lib/python2.7/site-packages/nose_gevented_multiprocess/nose_gevented_multiprocess.py", line 1034, in <module>
    individual_client_starter()
  File "/Users/kacarstensen/Documents/work/shift-virtualenv/lib/python2.7/site-packages/nose_gevented_multiprocess/nose_gevented_multiprocess.py", line 1031, in individual_client_starter
    start_test_processor_task_runner(worker_id, server_port)
  File "/Users/kacarstensen/Documents/work/shift-virtualenv/lib/python2.7/site-packages/nose_gevented_multiprocess/nose_gevented_multiprocess.py", line 482, in start_test_processor_task_runner
    task_runner.run_until_done()
  File "/Users/kacarstensen/Documents/work/shift-virtualenv/lib/python2.7/site-packages/nose_gevented_multiprocess/nose_gevented_multiprocess.py", line 216, in run_until_done
    self.setup()
  File "/Users/kacarstensen/Documents/work/shift-virtualenv/lib/python2.7/site-packages/nose_gevented_multiprocess/nose_gevented_multiprocess.py", line 367, in setup
    pickle.loads(loaderClass_serialized),
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1382, in loads
    return Unpickler(file).load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 858, in load
    dispatch[key](self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1090, in load_global
    klass = self.find_class(module, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1124, in find_class
    __import__(module)
TypeError: __import__() argument 1 must be string without null bytes, not str

To reproduce, it's sufficient to run the test suite with an option that enables the plugin, e.g. nosetests --gevented-processes=3 ... or nosetests --gevented-processes=-1 ....

This is on OS X 10.8.5 and Python 2.7.2. Other installed modules (if they matter):

Cython==0.18 Fabric==1.8.0 Flask==0.10.1 Flask-Classy==0.5 Flask-Testing==0.4 Jinja2==2.6 PIL==1.1.7 PyMemoize==0.1.1 Pygments==1.6 Sphinx==1.1.3 Werkzeug==0.8.3 XlsxWriter==0.3.6 amqp==1.0.13 anyjson==0.3.3 argparse==1.2.1 billiard==2.7.3.34 blessings==1.5.1 boto==2.8.0 celery==3.0.22 coverage==3.7.1 cql==1.4.0 cqlengine==0.10.0 docutils==0.11 ecdsa==0.10 flower==0.4.3 gevent==1.0 graypy==0.2.9 greenlet==0.4.1 httpretty==0.7.0 ipdb==0.7 ipdbplugin==1.2 ipython==1.0.0 itsdangerous==0.23 jsonrpcparts==0.3.4 kombu==2.5.16 logstash-formatter==0.5.7 meld3==0.6.10 mock==1.0.1 nose==1.3.0 nose-gevented-multiprocess==0.1.2 nose-progressive==1.5 oauthlib==0.6.0 openpyxl==1.6.2 paramiko==1.12.0 prettytable==0.7.1 psutil==1.2.1 py-serverdensity==1.0.12 pycallgraph==1.0.1 pycassa==1.10.0 pycrypto==2.6.1 pyes==0.20.0 pyparsing==1.5.7 python-dateutil==2.2 pytz==2013b readline==6.2.4.1 redis==2.7.2 requests==2.0.1 requests-cache==0.4.3 requests-oauthlib==0.4.0 shovel==0.1.9 six==1.4.1 sphinx-http-domain==0.2 statsd==1.0.0 supervisor==3.0b1 thrift==0.9.1 thunderdome==0.4.7 thunderdome-logging==1.0 tornado==3.1.1 twill==0.9 uWSGI==1.4.5 urllib3==1.6 wsgiref==0.1.2 xlrd==0.9.2 yolk==0.4.3

kacarstensen-shift commented 10 years ago

For whatever reason, the loader class, result class, and config get unpickled on the test runner processes as unicode objects instead of bytestrings. pickle.loads (on my machine at least) chokes on these, resulting in the errors above. If I use str() to convert the serialized objects to bytestrings before passing them to pickle.loads, it works fine. I'm not sure why this happens for me and not you, though.

kacarstensen-shift commented 10 years ago

See https://github.com/kacarstensen-shift/nose_gevent_multiprocess/commit/16568c51f6f2c6a014b272b39ed6257f394fbf60 for my fix.