GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PubSub subscription.pull() with return_immediately=True causes KeyError · Issue #1781 · googleapis/google-cloud-python

PubSub subscription.pull() with return_immediately=True causes KeyError #1781

New issue
Copy link
New issue
Copy link
Closed
Closed
PubSub subscription.pull() with return_immediately=True causes KeyError#1781
Copy link
Assignees
tseaver
Labels
api: pubsubIssues related to the Pub/Sub API.

Description

@joeholley
joeholley
opened on May 6, 2016
Issue body actions

Attempting to pull from a subscription of an empty topic with return_immediately set to 'True' causes an exception to be raised. This should return an empty result, not raise a KeyError in the module, correct?

Example code:

#!/usr/bin/env python
from gcloud import pubsub 

# Config 
PUBSUB_TOPIC_NAME = 'deleteme'
PUBSUB_SUB_NAME = 'delete_me'

ack_queues = {}
client = pubsub.Client(project="joeholley-mimus01")
topic = client.topic(PUBSUB_TOPIC_NAME)
sub = topic.subscription(PUBSUB_SUB_NAME)
if not topic.exists():
  topic.create()
if not sub.exists():
  sub.create()
while True:
  recv = sub.pull(return_immediately=True,max_messages=1)
  print "Received!"

Results:

Traceback (most recent call last):
  File "db/db_worker.py", line 135, in <module>
    recv = sub.pull(return_immediately=True,max_messages=1)
  File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/subscription.py", line 249, in pull
    self.full_name, return_immediately, max_messages)
  File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/connection.py", line 419, in subscription_pull
    return response['receivedMessages']
KeyError: 'receivedMessages'

Expected results:
recv should contain an empty list as per http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-subscription.html

Activity

  1. tseaver commented on May 6, 2016

    @tseaver
    tseaver
    on May 6, 2016
    Contributor
    More actions

    Thanks for the report! Should be fixed on master via dd38d66.

  2. tseaver
    closed this as completedon May 6, 2016
  3. tseaver
    added
    api: pubsubIssues related to the Pub/Sub API.
    on May 6, 2016
  4. JustinBeckwith
    assigned
    tseaver
    on Feb 1, 2021
  5. parthea
    added 2 commits that reference this issue on Mar 2, 2026

    fix: replace deprecated utcfromtimestamp (#1799)

    f27029f

    docs: update to use API (#1781)

    d329d6b
  6. chalmerlowe
    added a commit that references this issue on Mar 26, 2026

    chore: run bidi_tests independently (#1781)

    bd306e9
  7. parthea
    added a commit that references this issue on Apr 1, 2026

    feat: implement ai.classify() (#1781)

    0af6326
  8. parthea
    added a commit that references this issue on Sep 8, 2026

    docs: migrate code from googleapis/python-bigquery (#18303)

    23f9a74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.