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

Move debug statement with blocking future.result() call to add_done_callback #4174

Merged
merged 1 commit into from
Oct 13, 2017

Conversation

jeffkpayne
Copy link
Contributor

@jeffkpayne jeffkpayne commented Oct 12, 2017

Closes #4167

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 12, 2017
@@ -139,9 +139,12 @@ def on_response(self, response):

For each message, schedule a callback with the executor.
"""
def callback_completed(future):
logger.debug('Result: %s' % future.result())

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@tseaver tseaver added the api: pubsub Issues related to the Pub/Sub API. label Oct 13, 2017
@tseaver tseaver changed the title PubSub: Move debug statement with blocking future.result() call to future.add_done_callback in thread-based subscriber Policy's on_response() Move debug statement with blocking future.result() call to add_done_callback Oct 13, 2017
@lukesneeringer lukesneeringer merged commit c171fdc into googleapis:master Oct 13, 2017
@lukesneeringer
Copy link
Contributor

Thanks @jeffkpayne!

@jeffkpayne
Copy link
Contributor Author

@lukesneeringer NP! Funny, though, I was just working on a unit test to test that the calls actually happen asynchronously... Should I continue with that and open a new PR?

@jeffkpayne
Copy link
Contributor Author

It would be along the lines of:

def test_on_response():
    call_times = []

    def side_effect(*args, **kwargs):
        # list.append() is thread-safe.
        call_times.append(datetime.now())
        time.sleep(2)

    callback = mock.Mock(spec=())
    callback.side_effect = side_effect

    # Then, after the calls happen, test that the times are both more than a second ago, or something like that...

@lukesneeringer
Copy link
Contributor

lukesneeringer commented Oct 13, 2017

I would accept that as a system test (but not a unit test). :-) And yes, additional PR is of course welcome.

@lukesneeringer
Copy link
Contributor

P. S. pubsub 0.28.4 is going through CI to release now. (This was a serious enough bug that I wanted it out immediately.)

@dhermes
Copy link
Contributor

dhermes commented Oct 13, 2017

jeffkpayne added a commit to bomboradata/bombora-google-cloud-python that referenced this pull request Oct 14, 2017
jeffkpayne added a commit to bomboradata/bombora-google-cloud-python that referenced this pull request Oct 14, 2017
jeffkpayne added a commit to bomboradata/bombora-google-cloud-python that referenced this pull request Oct 14, 2017
…allbacks to complete. Guessing this test was succeeding before because of the bug fixed in googleapis#4174 itself.
tseaver pushed a commit that referenced this pull request Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants