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

unsubscribe prints warning in standard use case #173

Closed
kylemcdonald opened this issue Aug 22, 2020 · 1 comment
Closed

unsubscribe prints warning in standard use case #173

kylemcdonald opened this issue Aug 22, 2020 · 1 comment
Assignees
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: question Request for information or clarification. Not an issue.

Comments

@kylemcdonald
Copy link

Environment details

  • OS type and version: Ubuntu 18.04
  • Python version: Python 3.7.7
  • pip version: pip 20.2.1
  • google-cloud-firestore version: 1.8.1

Steps to reproduce

  1. Create a Firestore collection called "docs" and a single document with the id "sample"
  2. Run the code below.

Code example

from google.cloud import firestore
import threading

firestore_client = firestore.Client()
doc_ref = firestore_client.collection('docs').document('sample')
callback_done = threading.Event()
def on_snapshot(doc_snapshot, changes, read_time):
    for doc in doc_snapshot:
        print(doc.to_dict())
        callback_done.set()
doc_watch = doc_ref.on_snapshot(on_snapshot)
callback_done.wait(10)
doc_watch.unsubscribe()

This code prints "Background thread did not exit." But I'm following the code from this documentation directly, so it seems like a bug that a warning would be printed on normal behavior.

Debug log

DEBUG:google.auth._default:Checking None for explicit credentials as part of auth process...
DEBUG:google.auth._default:Checking Cloud SDK credentials as part of auth process...
DEBUG:google.auth._default:Checking None for explicit credentials as part of auth process...
DEBUG:google.auth._default:Checking Cloud SDK credentials as part of auth process...
DEBUG:google.api_core.bidi:Started helper thread Thread-ConsumeBidirectionalStream
DEBUG:google.api_core.bidi:waiting for recv.
DEBUG:google.auth.transport.requests:Making request: POST https://oauth2.googleapis.com/token
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.googleapis.com:443
DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None
DEBUG:google.api_core.bidi:recved response.
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: target change: 1
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: target change: ADD
DEBUG:google.api_core.bidi:waiting for recv.
DEBUG:google.api_core.bidi:recved response.
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: document change
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: document change: CHANGED
DEBUG:google.api_core.bidi:waiting for recv.
DEBUG:google.api_core.bidi:recved response.
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: target change: 3
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: target change: CURRENT
DEBUG:google.api_core.bidi:waiting for recv.
DEBUG:google.api_core.bidi:recved response.
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: target change: 0
DEBUG:google.cloud.firestore_v1.watch:on_snapshot: target change: NO_CHANGE
DEBUG:google.cloud.firestore_v1.watch:walk over add_changes
DEBUG:google.cloud.firestore_v1.watch:in add_changes
DEBUG:google.api_core.bidi:waiting for recv.
DEBUG:google.cloud.firestore_v1.watch:Stopping consumer.
INFO:google.cloud.firestore_v1.watch:RPC termination has signaled manager shutdown.
DEBUG:google.api_core.bidi:Cleanly exiting request generator.
DEBUG:google.api_core.bidi:Call to retryable <bound method ResumableBidiRpc._recv of <google.api_core.bidi.ResumableBidiRpc object at 0x7f6bc94633d0>> caused <_MultiThreadedRendezvous of RPC that terminated with:
	status = StatusCode.CANCELLED
	details = "Locally cancelled by application!"
	debug_error_string = "None"
>.
DEBUG:google.api_core.bidi:Terminating <bound method ResumableBidiRpc._recv of <google.api_core.bidi.ResumableBidiRpc object at 0x7f6bc94633d0>> due to <_MultiThreadedRendezvous of RPC that terminated with:
	status = StatusCode.CANCELLED
	details = "Locally cancelled by application!"
	debug_error_string = "None"
>.
DEBUG:google.api_core.bidi:recved response.
WARNING:google.api_core.bidi:Background thread did not exit.
DEBUG:google.cloud.firestore_v1.watch:Finished stopping manager.
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Aug 22, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Aug 22, 2020
@HemangChothani
Copy link
Contributor

@kylemcdonald This issue is related to the googleapis/google-cloud-python#7826 issue, the scenario is deadlock happens in BackgroundConsumer.stop, because of ill-behaved daemon threads during BiDi shutdown, so this issue has been handled in the PR googleapis/google-cloud-python#9337 to avoid blocking and raised warning, but after that they have stopped manager forcefully. The issue is still open in api-core lib https://github.com/googleapis/python-api-core/issues/4 .

@HemangChothani HemangChothani added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Aug 25, 2020
@tseaver tseaver closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants