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 — [Documentation Issue] Pub/Sub default max_messages is unclear in 0.13.0 docs · Issue #1756 · googleapis/google-cloud-python

[Documentation Issue] Pub/Sub default max_messages is unclear in 0.13.0 docs #1756

New issue
Copy link
New issue
Copy link
Closed
Closed
[Documentation Issue] Pub/Sub default max_messages is unclear in 0.13.0 docs#1756
Copy link
Assignees
tseaver
Labels
api: pubsubIssues related to the Pub/Sub API.

Description

@joeholley
joeholley
opened on Apr 26, 2016
Issue body actions

Page Name: pubsub-usage
Release: 0.13.0

This section:

Fetch pending messages for a pull subscription:

>>> from gcloud import pubsub
>>> client = pubsub.Client()
>>> topic = client.topic('topic_name')
>>> subscription = topic.subscription('subscription_name')
>>> with topic.batch() as batch:
...     batch.publish('this is the first message_payload')
...     batch.publish('this is the second message_payload',
...                   attr1='value1', attr2='value2')
>>> received = subscription.pull()  # API request
>>> messages = [recv[1] for recv in received]
>>> [message.message_id for message in messages]
[<message_id1>, <message_id2>]
>>> [message.data for message in messages]
['this is the first message_payload', 'this is the second message_payload']
>>> [message.attributes for message in messages]
[{}, {'attr1': 'value1', 'attr2': 'value2'}]

Does not pull all pending messages in my very simple test code. It only pulls one pending message. I can get multiple by specifying 'max_messages' greater than 1 in the 'subscription.pull()' call.

Has something changed in the implementation since this doc was written?

Activity

  1. joeholley commented on Apr 26, 2016

    @joeholley
    joeholley
    on Apr 26, 2016
    Author
    More actions

    Tested with two simple scripts: one that publishes one message a second on infinite loop, and one that does subscription.pull() once per 10 seconds on an infinite loop. No args for subscription.pull() results in one message received. Specifying max_messages > 1 will allow me to get multiple in one pull.

  2. joeholley commented on Apr 26, 2016

    @joeholley
    joeholley
    on Apr 26, 2016
    Author
    More actions

    Does look like http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-subscription.html#gcloud.pubsub.subscription.Subscription.pull shows a default value of 1 specified for the max_messages arg. Documentation should be updated, I guess?

  3. tseaver
    self-assigned this
    on Apr 26, 2016
  4. tseaver commented on Apr 26, 2016

    @tseaver
    tseaver
    on Apr 26, 2016
    Contributor
    More actions

    Thanks for the report! I will update the docs.

  5. dhermes commented on Apr 27, 2016

    @dhermes
    dhermes
    on Apr 27, 2016
    Contributor
    More actions

    @tmatsuo Is there a better default than 1 for max_messages?


    @tseaver I would give you the line in pubsub-usage.rst where received = subscription.pull() # API request should be changed, but GitHub doesn't allow linking into RST or MD files, so I can't.

    @joeholley Do you think a suitable change would be to just change that line to

    received = subscription.pull(max_messages=2)

    or do you think there should be a separate example showcasing that the default is 1?


    @joeholley RE: Subscription.pull shows a default value of 1, that is what's in the actual code. I'm not sure how familiar you are with Sphinx, but most of the module docs are completely generated by Sphinx with no curation by us, and that includes the defaults for keyword arguments.

  6. tseaver
    added
    docs
    api: pubsubIssues related to the Pub/Sub API.
    on Apr 28, 2016
  7. tseaver commented on Apr 28, 2016

    @tseaver
    tseaver
    on Apr 28, 2016
    Contributor
    More actions

    @dhermes the actual snippet on master is now being pulled from docs/pubsub_snippets.py, and shows the max_messages argument.

  8. dhermes commented on Apr 28, 2016

    @dhermes
    dhermes
    on Apr 28, 2016
    Contributor
    More actions

    Nice! I forgot about that. w00t!

    So the issue is that 0.13.0 is out of date.

    @joeholley Does that resolve your issue? Also, in general, when filing a docs bug, double check latest before filing, since stable and 0.x.y are docs that will be frozen at the time they were generated.

  9. dhermes
    changed the title [-][Documentation Issue] [/-] [+][Documentation Issue] Pub/Sub default max_messages is unclear in 0.13.0 docs[/+] on Apr 28, 2016
  10. tseaver commented on Apr 28, 2016

    @tseaver
    tseaver
    on Apr 28, 2016
    Contributor
    More actions

    @joeholley please reopen if needed.

  11. tseaver
    closed this as completedon Apr 28, 2016
  12. tmatsuo commented on May 3, 2016

    @tmatsuo
    tmatsuo
    on May 3, 2016
    Contributor
    More actions

    @dhermes I think it is a mandatory parameter for the core API. Having 1 as a default in this layer seems reasonable.

  13. dhermes commented on May 3, 2016

    @dhermes
    dhermes
    on May 3, 2016
    Contributor
    More actions

    Thanks @tmatsuo!

  14. joeholley commented on May 3, 2016

    @joeholley
    joeholley
    on May 3, 2016
    Author
    More actions

    Weird; the click-to-generate-issue functionality I used to make this ticket doesn't actually tell you exactly which docs page (via path) I was referencing.

    To be clear, I was referring to http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-usage.html , which AFAICT is

    • not an sphinx-genned page,
    • is current live on the site, and
    • does not reflect the implementation in the lastest version of the gcloud python module that will be pulled by users doing a 'pip install gcloud' today.

    So the section I quoted still needs to be updated manually, looks like? In addition there's a portion of the docs a bit after the example quoted where it specifically calls out the max_messages=1 param as a way to get only one message

    Fetch a limited number of pending messages for a pull subscription:

    >> from gcloud import pubsub
    >> client = pubsub.Client()
    >> topic = client.topic('topic_name')
    >> subscription = topic.subscription('subscription_name')
    >> with topic.batch() as batch:
    ...     batch.publish('this is the first message_payload')
    ...     batch.publish('this is the second message_payload',
    ...                   attr1='value1', attr2='value2')
    >> received = subscription.pull(max_messages=1)  # API request
    >> messages = [recv[1] for recv in received]
    >> [message.message_id for message in messages]
    

    (When that the default behavior, having an example callout referencing it doesn't make sense.)

    @tmatsuo No issues with the default being one, just need the docs to reflect that.

  15. joeholley commented on May 3, 2016

    @joeholley
    joeholley
    on May 3, 2016
    Author
    More actions

    @tseaver - I can't re-open a github issue I didn't close in this repo since I'm not a repo collaborator :D

  16. dhermes
    reopened this on May 3, 2016
  17. tseaver commented on May 3, 2016

    @tseaver
    tseaver
    on May 3, 2016
    Contributor
    More actions

    To be clear, I was referring to http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-usage.html , which AFAICT is

    Note that you are referencing the stable version (as of the last release), ratther than the latest version (built from the master branch).

    not an sphinx-genned page,

    It is generated by Sphinx (see the source). The example snippets are now (on master) pulled from a separate Python script, which allows them to be tested against the actual API.

    is current live on the site, and

    (see above)

    does not reflect the implementation in the lastest version of the gcloud python module that will be pulled by users doing a 'pip install gcloud' today.

    The stable version gets updated as we make new releases.

  18. joeholley commented on May 3, 2016

    @joeholley
    joeholley
    on May 3, 2016
    Author
    More actions

    Okay, I understand what you're saying here, but the fact remains that someone who uses gcloud python today for the first time and does a 'pip install gcloud' gets different functionality than what is used in examples on the publicly facing docs site. If a new release of gcloud has been cut and put on pip, why has a new release of the docs not been cut and put on the documentation website? Shouldn't these two should be in lockstep to avoid confusion for users?

  19. dhermes commented on May 3, 2016

    @dhermes
    dhermes
    on May 3, 2016
    Contributor
    More actions

    This convention is a very common one (the default one on readthedocs.org). stable is our latest release (the one people get when they pip install) and latest is re-built / re-deployed every time we push to master.

  20. joeholley commented on May 4, 2016

    @joeholley
    joeholley
    on May 4, 2016
    Author
    More actions

    I'm really sorry, but I'm still confused. The version I got when running pip install gcloud does not match the documentation I get when I go to http://googlecloudplatform.github.io/gcloud-python/ - in both cases (the package, and the docs), I'm not specifying any version. Shouldn't it be safe for me to assume that the default docs on the doc page are for the default package version pulled via pip? It seems to me that you two are saying that they should match, but in fact it doesn't (or didn't, 8 days ago when I made this issue).

    @tseaver said:

    To be clear, I was referring to http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-usage.html , which AFAICT is

    Note that you are referencing the stable version

    which I read as "you are referencing the docs for the 'stable' tagged build of the gcloud python module"

    @dhermes said:

    This convention is a very common one (the default one on readthedocs.org). stable is our latest release (the one people get when they pip install)

    which I read as "when you run pip install, you get the 'stable' tagged build of gcloud python module".

    Again, sorry, I'm not trying to be obtuse! These two comments seem to be at odds, since the functionality of the module ('stable' version, as per @dhermes) and the documented functionality ('stable' version, as per @tseaver) don't match?

  21. dhermes commented on May 4, 2016

    @dhermes
    dhermes
    on May 4, 2016
    Contributor
    More actions

    Sorry, let me make it more digestible

    1. Visit googlecloudplatform.github.io/gcloud-python and click the red "Read the Docs" button
    2. Visit http://googlecloudplatform.github.io/gcloud-python/stable/
    3. Note the "Version History: 0.13.0" in the box
    4. Visit https://pypi.python.org/pypi/gcloud
    5. Note that 0.13.0 is the latest version
  22. joeholley commented on May 4, 2016

    @joeholley
    joeholley
    on May 4, 2016
    Author
    More actions

    @dhermes

    I'm very sorry; apparently I'm failing to explain this in an understandable way. Let me try to mirror your approach. Please follow along if you like, to see the issue at hand.

    1. Visit googlecloudplatform.github.io/gcloud-python and click the red "Read the Docs" button
    2. Under 'Pub/Sub' on the left, click 'Using the API'. This takes you to http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-usage.html . Leave this page open, we'll be cutting/pasting code from it in a step below. NOTE: I have not selected any version of the docs page. This is the default version of the docs page any average user will navigate to.
    3. Open a local shell on any machine where you have the gcloud cli configured and authorized to start GCE instances. Run the following to stand up a fresh GCE instance using the latest official GCE Ubuntu image, and then ssh to that VM. NOTE: this shows that the machine running the example code has no environment customization. It is exactly how an average user would begin with a fresh OS install:
    gcloud compute instances create example-instance-2 --machine-type=g1-small --image=ubuntu-15-10 --scope=cloud-platform
    gcloud compute ssh example-instance-2
    
    1. (now on the GCE instance), Install the default pip package and the default gcloud module. NOTE, we are not specifying any versions here either. These are the default versions any average user will receive when running these commands:
    sudo apt-get -y install python-pip && pip install gcloud
    
    1. Open an editor and cut/paste the following example code from the page in step 2 (http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-usage.html) into a file named test.py:
    # http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-usage.html               
    # Fetch pending messages for a pull subscription:          
    
    from gcloud import pubsub                                  
    client = pubsub.Client()                                   
    topic = client.topic('topic_name')                         
    topic.create() # create a new topic as per example page    
    subscription = topic.subscription('subscription_name')     
    subscription.create() # create a new subscription as per the example page                   
    with topic.batch() as batch:                               
        batch.publish('this is the first message_payload')     
        batch.publish('this is the second message_payload', attr1='value1', attr2='value2')     
    received = subscription.pull()  # API request              
    messages = [recv[1] for recv in received] # Should have received two messages as per the example page
    print [message.message_id for message in messages] # Should print two message_ids per the example page
    print [message.data for message in messages] # should print two messages per the example page     
    

    NOTE: ALL of the above code is VERBATIM from the referenced docs page. As per that docs page, expected output is (again, cut/pasted VERBATIM from the referenced docs page):

    [<message_id1>, <message_id2>]
    ['this is the first message_payload', 'this is the second message_payload']
    
    1. Run the test script on the GCE instance, using
      python ./test.py.
      Observe the output:
    [u'32367764065423']
    ['this is the first message_payload']
    

    I honestly don't know how to make this any clearer. When installing the default version of the gcloud python module from pip, and directly referencing the examples on the default version of the docs that are live on http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-usage.html, the examples given do NOT produce the output from the examples page, and the examples page needs to be updated.

    I hope this helps.

  23. dhermes commented on May 5, 2016

    @dhermes
    dhermes
    on May 5, 2016
    Contributor
    More actions

    The section is no longer present in the docs. New "stable" docs don't get created unless we cut a release. The docs fix can be seen in http://googlecloudplatform.github.io/gcloud-python/latest/pubsub-usage.html#pull-messages-from-a-subscription This docs fix will be in stable in the next release.

  24. joeholley
    closed this as completedon May 5, 2016
  25. parthea
    added a commit that references this issue on Nov 26, 2025

    fix: disable logging response body for async logs (#1756)

    9601cac
  26. parthea
    added a commit that references this issue on Mar 9, 2026

    fix: pass token correctly, '&' instead of ',' (#1756)

    d240a2a
  27. chalmerlowe
    added a commit that references this issue on Mar 26, 2026

    chore: librarian release pull request: 20260318T145147Z (#1776)

    ba01cdb
  28. parthea
    added a commit that references this issue on Apr 1, 2026

    feat: add bbq.json_query and warn bbq.json_extract deprecated (#1756)

    e8b329a
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.