Skip to content

Unable to receive messages after prolonged network disconnection #1379

Open
@bernardboey

Description

@bernardboey

Environment details

  • OS type and version: Tested on both Windows 11 and WSL (Ubuntu 24.04.2)
  • Python version: Python 3.12.3
  • pip version: pip 24.0
  • google-cloud-pubsub version: 2.29.0

Steps to reproduce

  1. Run the script below
  2. Publish message 1 to the topic
  3. Observe that message 1 is received and printed out
  4. Disconnect from the internet for 1 minute
  5. Reconnect to the internet
  6. Publish message 2 to the topic
  7. Observe that message 2 is not received
  8. After terminating the script, there was a log Background thread did not exit.

Expected behaviour

The library should either:
(a) be able to reconnect and receive message 2, or
(b) raise an exception upon unrecoverable network disconnection, so that the caller can catch and recover (e.g. restart)

Code example

from google.cloud import pubsub_v1

subscriber_client = pubsub_v1.SubscriberClient()

subscription = subscriber_client.subscription_path(PROJECT, SUBSCRIPTION)

def callback(message):
    print(message)
    message.ack()

future = subscriber_client.subscribe(subscription, callback)
try:
    future.result()
except KeyboardInterrupt:
    future.cancel()
    future.result()

Stack trace

No stack trace as no exception was raised. However, there was a log of Background thread did not exit. after terminating the script

Pip freeze

aio-pika==9.4.3
aioboto3==13.1.1
aiobotocore==2.13.1
aiofiles==24.1.0
aiohappyeyeballs==2.4.3
aiohttp==3.10.9
aioitertools==0.12.0
aiormq==6.8.1
aiosignal==1.3.1
annotated-types==0.7.0
anyio==4.6.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
attrs==24.2.0
beanie==1.27.0
blinker==1.8.2
boto3==1.34.131
botocore==1.34.131
build==1.2.2.post1
cachetools==5.5.2
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
decorator==5.2.1
Deprecated==1.2.18
distro==1.9.0
dnspython==2.7.0
Flask==3.0.3
Flask-Cors==5.0.0
Flask-JWT-Extended==4.6.0
frozenlist==1.4.1
google-api-core==2.24.1
google-auth==2.38.0
google-cloud-pubsub==2.29.0
googleapis-common-protos==1.69.1
grpc-google-iam-v1==0.14.1
grpcio==1.71.0rc2
grpcio-status==1.71.0rc2
h11==0.14.0
httpcore==1.0.6
httpx==0.27.2
idna==3.10
imageio==2.37.0
imageio-ffmpeg==0.6.0
importlib_metadata==8.5.0
itsdangerous==2.2.0
Jinja2==3.1.4
jiter==0.6.1
jmespath==1.0.1
lazy-model==0.2.0
MarkupSafe==3.0.1
motor==3.6.0
motor-types==1.0.0b4
moviepy==2.1.2
multidict==6.1.0
numpy==2.2.3
openai==1.51.2
opentelemetry-api==1.30.0
opentelemetry-sdk==1.30.0
opentelemetry-semantic-conventions==0.51b0
packaging==24.2
pamqp==3.3.0
pika==1.3.2
pika-stubs==0.1.3
pillow==10.4.0
pillow_heif==0.18.0
pip-tools==7.4.1
proglog==0.1.10
propcache==0.2.0
proto-plus==1.26.0
protobuf==5.29.3
pyasn1==0.6.1
pyasn1_modules==0.4.1
pycparser==2.22
pydantic==2.9.2
pydantic-mongo==2.3.0
pydantic_core==2.23.4
PyJWT==2.9.0
pymongo==4.9.2
pyproject_hooks==1.2.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-http-client==3.3.7
python-telegram-bot==21.6
pytz==2024.2
requests==2.32.3
rsa==4.9
s3transfer==0.10.3
sendgrid==6.11.0
setuptools==78.1.0
six==1.16.0
sniffio==1.3.1
starkbank-ecdsa==2.2.0
toml==0.10.2
tqdm==4.66.5
typing_extensions==4.12.2
urllib3==2.2.3
Werkzeug==3.0.4
wheel==0.45.1
wrapt==1.16.0
yarl==1.14.0
zipp==3.21.0

Metadata

Metadata

Labels

api: pubsubIssues related to the googleapis/python-pubsub API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions