Skip to content

PubSub: dispatch_callback errors after cancel() of a subscription #6130

@udim

Description

@udim

OS: Linux 4.17.0-3rodete2-amd64, Debian 4.17.17-1rodete2
Python 2.7.13
google-cloud-pubsub 0.35.4

Stacktrace 1

ERROR:google.cloud.pubsub_v1.subscriber._protocol.helper_threads:Error in queue callback worker: 'NoneType' object has no attribute 'is_paused'
Traceback (most recent call last):
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py", line 112, in __call__
    self._callback(items)
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py", line 101, in dispatch_callback
    self.ack(batched_commands.pop(requests.AckRequest))
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py", line 124, in ack
    self.drop(items)
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py", line 133, in drop
    self._manager.maybe_resume_consumer()
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py", line 224, in maybe_resume_consumer
    if not self._consumer.is_paused:
AttributeError: 'NoneType' object has no attribute 'is_paused'

Stacktrace 2

ERROR:google.cloud.pubsub_v1.subscriber._protocol.helper_threads:Error in queue callback worker: 'NoneType' object has no attribute 'remove'
Traceback (most recent call last):
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py", line 112, in __call__
    self._callback(items)
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py", line 101, in dispatch_callback
    self.ack(batched_commands.pop(requests.AckRequest))
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py", line 124, in ack
    self.drop(items)
  File "/usr/local/google/home/ehudm/virtualenvs/beamenv/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py", line 132, in drop
    self._manager.leaser.remove(items)
AttributeError: 'NoneType' object has no attribute 'remove'

Steps to reproduce

event = threading.Event()
def message_cb(msg):
  msg.ack()
  event.set()
sub_client = pubsub.SubscriberClient()
sub_future = sub_client.subscribe(sub_name, message_cb)
event.wait()
sub_future.cancel()

This subscription should be canceled approximately after the first message. In my test there are two messages sent to the topic and event.set() is called after the second.

I realize that calling cancel() so soon prevents the ack from being sent. Is there a cleaner way to stop the subscription?

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: pubsubIssues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions