-
Notifications
You must be signed in to change notification settings - Fork 563
PYTHON-973: Use global variable for libev loops so it can be subclassed #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -72,24 +71,25 @@ def test_watchers_are_finished(self): | |||
|
|||
@test_category connection | |||
""" | |||
with patch.object(LibevConnection._libevloop, "_thread"),\ | |||
patch.object(LibevConnection._libevloop, "notify"): | |||
from cassandra.io.libevreactor import _global_loop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the import has to happen here so the it happens after _global_loop
is initialized, if it's imported at the beginning, _global_loop
is None
@@ -125,7 +125,8 @@ def create_timer(self): | |||
|
|||
@property | |||
def _timers(self): | |||
return self.connection._libevloop._timers | |||
from cassandra.io.libevreactor import _global_loop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Code looks good! 2 things:
|
It's hard to add in a test that fails on master and passes here because of the following: Case 1
Case 2
In our tests in I think we can test that As for the pypy issue looks like gevent is not being installed in pypy (this is happening in master as well). There was a release 4 days ago so it's probably related to this. |
Ohhhh, interesting -- I see what's up with the test. So does cassandra.io.libevreactor._global_loop._cleanup()
cassandra.io.libevreactor._global_loop = None not set things up to avoid the "subclasses use parent event loop" problem? I don't know that I follow that. |
Yeah that's correct. That stops the libev loop and the tests verifies:
Before:
But before also happened:
|
I'll add a similar test to the asyncore one here |
Tests ran clean using libev; merging. |
This PR is very similar to #941, so some of the review comments there might apply here as well @mambocab