-
Notifications
You must be signed in to change notification settings - Fork 214
Closed
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.Issues related to the googleapis/python-pubsub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Environment details
- OS type and version: macOS 11.4
- Python version: 3.8.2
- pip version: 21.1.3
google-cloud-pubsubversion: 2.7.0
Steps to reproduce
- Install
google-cloud-pubsub, e.g.pipenv install --python 3.8 google-cloud-pubsub. - Run code below.
Code example
from concurrent.futures import TimeoutError
from typing import Callable
from google.cloud.pubsub_v1 import SubscriberClient
from google.cloud.pubsub_v1.types import PubsubMessage
def process_messages(
project_id: str,
subscription_id: str,
callback: Callable[[PubsubMessage], None],
timeout: int = 5,
) -> None:
subscriber = SubscriberClient()
subscription_path = subscriber.subscription_path(project_id, subscription_id)
streaming_pull_future = subscriber.subscribe(subscription_path, callback=callback)
with subscriber:
try:
streaming_pull_future.result(timeout=timeout)
except TimeoutError:
streaming_pull_future.cancel() # Trigger the shutdown.
streaming_pull_future.result() # Block until the shutdown is complete.
if __name__ == "__main__":
process_messages("my-project", "my-sub")Stack trace
Traceback (most recent call last):
File "loaders.py", line 4, in <module>
from google.cloud.pubsub_v1 import SubscriberClient
File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/__init__.py", line 19, in <module>
from google.cloud.pubsub_v1 import subscriber
File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/__init__.py", line 17, in <module>
from google.cloud.pubsub_v1.subscriber.client import Client
File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/client.py", line 26, in <module>
from google.cloud.pubsub_v1.subscriber._protocol import streaming_pull_manager
File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py", line 35, in <module>
import google.cloud.pubsub_v1.subscriber.message
File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/message.py", line 20, in <module>
import pytz
ModuleNotFoundError: No module named 'pytz'
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.Issues related to the googleapis/python-pubsub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.