Skip to content
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

Merged
merged 9 commits into from
Nov 2, 2018

Conversation

chrisrossi
Copy link

Does not implement RPC integration.

@chrisrossi chrisrossi requested a review from crwilcox as a code owner October 31, 2018 19:07
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 31, 2018
self.queue = []
self.rpcs = {}

def clear(self):

This comment was marked as spam.

_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.

This comment was marked as spam.

This comment was marked as spam.

_, 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.

This comment was marked as spam.

This comment was marked as spam.

@chrisrossi chrisrossi requested review from dhermes and tseaver October 31, 2018 19:18
@chrisrossi chrisrossi changed the title WIP. First pass at ndb.eventloop.EvenLoop implementation. WIP. First pass at ndb.eventloop.EventLoop implementation. Oct 31, 2018
@chrisrossi
Copy link
Author

I'm not sure I can make heads or tails of the CircleCI failure. Seems to have something to do with google.cloud.asset

@tseaver
Copy link
Contributor

tseaver commented Oct 31, 2018

@chrisrossi The CI failure is breakage from googleapis-common-protos 1.5.4: see PR #6355.

Or maybe the generated asset docstring breakage addressed in PR #6351.

@tseaver
Copy link
Contributor

tseaver commented Oct 31, 2018

@chrisrossi A rebase against the current master should get you back to green on CircleCI.

ndb/src/google/cloud/ndb/eventloop.py Outdated Show resolved Hide resolved
ndb/src/google/cloud/ndb/eventloop.py Outdated Show resolved Hide resolved
_, 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.

@chrisrossi
Copy link
Author

@chrisrossi A rebase against the current master should get you back to green on CircleCI.

Yep, thanks!

@dhermes
Copy link
Contributor

dhermes commented Oct 31, 2018

FYI @tseaver I'm in the middle of a review, but holding back until done (sorry I didn't announce).

@dhermes dhermes closed this Oct 31, 2018
@dhermes dhermes reopened this Oct 31, 2018
Copy link
Contributor

@dhermes dhermes left a 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:

  1. Splitting future PRs into smaller chunks (i.e. one commit per method)
  2. 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.

This comment was marked as spam.

ndb/src/google/cloud/ndb/eventloop.py Outdated Show resolved Hide resolved


class EventLoop:
__slots__ = ()
"""Constructor.

This comment was marked as spam.

This comment was marked as spam.


def __init__(self, *args, **kwargs):
Fields:

This comment was marked as spam.

This comment was marked as spam.

ndb/src/google/cloud/ndb/eventloop.py Outdated Show resolved Hide resolved
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.

ndb/tests/unit/test_eventloop.py Outdated Show resolved Hide resolved
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.

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.

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.

ndb/src/google/cloud/ndb/eventloop.py Show resolved Hide resolved
rpcs.clear()
_logging_debug('Cleared')

def insort_event_right(self, event):

This comment was marked as spam.

"""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.

This comment was marked as spam.

@chrisrossi chrisrossi merged commit 36ffa92 into googleapis:master Nov 2, 2018
@chrisrossi chrisrossi deleted the ndb-eventloop branch November 2, 2018 17:57
chrisrossi pushed a commit to chrisrossi/google-cloud-python that referenced this pull request Feb 22, 2019
…is#6353)

Implements `ndb.eventloop.EventLoop` except for integration with RPC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants