-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
WIP. First pass at ndb.eventloop.EventLoop implementation. #6353
Conversation
self.queue = [] | ||
self.rpcs = {} | ||
|
||
def clear(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
_logging_debug(' queue = %s', queue) | ||
if rpcs: | ||
_logging_debug(' rpcs = %s', rpcs) | ||
self.__init__(self.clock) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
_, callback, args, kwargs = self.queue.pop(0) | ||
_logging_debug('event: %s', callback.__name__) | ||
callback(*args, **kwargs) | ||
# TODO: What if it raises an exception? |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I'm not sure I can make heads or tails of the CircleCI failure. Seems to have something to do with |
@chrisrossi The CI failure is breakage from Or maybe the generated |
@chrisrossi A rebase against the current |
…nt RPC integration.
d40ea9b
to
c69a532
Compare
_, callback, args, kwargs = self.queue.pop(0) | ||
_logging_debug('event: %s', callback.__name__) | ||
callback(*args, **kwargs) | ||
# TODO: What if it raises an exception? |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Yep, thanks! |
FYI @tseaver I'm in the middle of a review, but holding back until done (sorry I didn't announce). |
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.
Thanks for sending this. Sorry for the boatload of comments. Would you mind either:
- Splitting future PRs into smaller chunks (i.e. one commit per method)
- Sending smaller PRs?
With this many things flying around it can be hard to track all review comments.
def _noop(*args, **kw): | ||
"""Do nothing.""" | ||
|
||
# TODO: Use utils.logging_debug when implemented |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
class EventLoop: | ||
__slots__ = () | ||
"""Constructor. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
def __init__(self, *args, **kwargs): | ||
Fields: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ndb/tests/unit/test_eventloop.py
Outdated
ev.queue.append('baz') | ||
ev.rpcs['qux'] = 'quux' | ||
ev.clear() | ||
assert not len(ev.current) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ndb/tests/unit/test_eventloop.py
Outdated
def test_constructor(): | ||
def _make_one(**attrs): | ||
"""Use DummyClock""" | ||
ev = eventloop.EventLoop(DummyClock()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ndb/tests/unit/test_eventloop.py
Outdated
assert ev.clock is myclock | ||
|
||
def test_clear_current(self): | ||
""" For branch coverage. """ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ndb/tests/unit/test_eventloop.py
Outdated
class DummyClock: | ||
"""Fake out clock class without having to actually read system clock or | ||
sleep during tests. | ||
""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
rpcs.clear() | ||
_logging_debug('Cleared') | ||
|
||
def insort_event_right(self, event): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
"""Schedule a function call at a specific time in the future. | ||
|
||
Arguments: | ||
delay (number): Time in seconds to delay running the callback. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
…is#6353) Implements `ndb.eventloop.EventLoop` except for integration with RPC.
Does not implement RPC integration.