Skip to content

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

Merged
lukesneeringer merged 1 commit into
googleapis:masterfrom
bomboradata:master
Oct 13, 2017
Merged

Move debug statement with blocking future.result() call to add_done_callback#4174
lukesneeringer merged 1 commit into
googleapis:masterfrom
bomboradata:master

Conversation

@jeffkpayne

@jeffkpaynejeffkpayne commented Oct 12, 2017

Copy link
Copy Markdown
Contributor

Closes#4167

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 12, 2017
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.

@tseavertseaver added the api: pubsub Issues related to the Pub/Sub API. label Oct 13, 2017
@tseavertseaver 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_callbackOct 13, 2017
@lukesneeringer
lukesneeringer merged commit c171fdc into googleapis:masterOct 13, 2017
@lukesneeringer

Copy link
Copy Markdown
Contributor

Thanks @jeffkpayne!

@jeffkpayne

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
ContributorAuthor

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

lukesneeringer commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

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

@lukesneeringer

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
parthea pushed a commit that referenced this pull request Mar 2, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: pubsubIssues related to the Pub/Sub API.cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jeffkpayne@lukesneeringer@dhermes@tseaver@googlebot