Pull request gevent check #207

Merged
merged 3 commits into from Sep 12, 2013

Conversation

Projects
None yet
4 participants
Contributor

pvicente commented Nov 12, 2012

Sometimes gevent has been loaded as module but monkey patch has not been performed. (f.e: Pymongo is doing it)

With the patch I propose to check if system thread module has been "monkey patched" with gevent and then do the right import of Queue.

Also I have added a parameter on testall.py to check the testsuite with gevent enabled/disabled.

Time elapsed doing the test suite has been improved a lot (at my desktop from 30 to 10 seconds)

Contributor

jpcaruana commented Jul 25, 2013

+1

seocam commented Sep 12, 2013

Definitely needing it! 💯

I'm getting the error NotImplementedError: gevent is only usable from a single thread. After applying this patch the error is gone.

My code is just like the registration example provided by SleekXMPP but running on a Django project.

The file is here: https://github.com/TracyWebTech/django-conversejs/blob/master/conversejs/register.py

Stack trace:

Exception in thread scheduler_thread:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/vagrant/.virtualenvs/colab/local/lib/python2.7/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1742, in _scheduler_thread
    self.scheduler.process(threaded=False)
  File "/home/vagrant/.virtualenvs/colab/local/lib/python2.7/site-packages/sleekxmpp/xmlstream/scheduler.py", line 135, in process
    self._process()
  File "/home/vagrant/.virtualenvs/colab/local/lib/python2.7/site-packages/sleekxmpp/xmlstream/scheduler.py", line 185, in _process
    self.schedule_lock.release()
  File "/usr/lib/python2.7/threading.py", line 142, in release
    raise RuntimeError("cannot release un-acquired lock")
RuntimeError: cannot release un-acquired lock

Exception in thread event_thread_0:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/vagrant/.virtualenvs/colab/local/lib/python2.7/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1623, in _event_runner
    event = self.event_queue.get(True, timeout=wait)
  File "/home/vagrant/.virtualenvs/colab/local/lib/python2.7/site-packages/gevent/queue.py", line 190, in get
    return waiter.get()
  File "/home/vagrant/.virtualenvs/colab/local/lib/python2.7/site-packages/gevent/hub.py", line 321, in get
    return get_hub().switch()
  File "/home/vagrant/.virtualenvs/colab/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

seocam commented Sep 12, 2013

@legastero could you please take a look to see if it's ok to be merged?

Sorry to bother you :)

legastero added a commit that referenced this pull request Sep 12, 2013

@legastero legastero merged commit 07284f3 into fritzy:develop Sep 12, 2013

seocam commented Sep 12, 2013

Awesome!! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment