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 — unused message arg in Batch.will_accept() · Issue #105 · googleapis/python-pubsub

This repository was archived by the owner on Oct 13, 2026. It is now read-only.
This repository was archived by the owner on Oct 13, 2026. It is now read-only.

unused message arg in Batch.will_accept() #105

Copy link
Copy link
Closed
#108
Closed
unused message arg in Batch.will_accept()#105
#108
Copy link
Assignees
IlyaFaer
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.type: cleanupAn internal cleanup or hygiene concern.

Description

@IlyaFaer
IlyaFaer
opened on May 27, 2020
Issue body actions

Looks like message arg is never used by will_accept() method:

python-pubsub/google/cloud/pubsub_v1/publisher/_batch/base.py

Lines 112 to 136 in cf9e87c

def will_accept(self, message):
"""Return True if the batch is able to accept the message.
In concurrent implementations, the attributes on the current batch
may be modified by other workers. With this in mind, the caller will
likely want to hold a lock that will make sure the state remains
the same after the "will accept?" question is answered.
Args:
message (~.pubsub_v1.types.PubsubMessage): The Pub/Sub message.
Returns:
bool: Whether this batch can accept the message.
"""
# If this batch is not accepting messages generally, return False.
if self.status != BatchStatus.ACCEPTING_MESSAGES:
return False
# If this message will make the batch exceed the ``max_messages``
# setting, return False.
if len(self.messages) >= self.settings.max_messages:
return False
# Okay, everything is good.
return True

Most likely it should be deleted to avoid any confusion, but I suppose it should be done with deprecation. Batch() is not something pretending to be manually used by users, but who knows.

@pradn, please, comment

Activity

  1. IlyaFaer
    added
    api: pubsubIssues related to the googleapis/python-pubsub API.
    type: cleanupAn internal cleanup or hygiene concern.
    on May 27, 2020
  2. IlyaFaer
    self-assigned this
    on May 27, 2020
  3. pradn commented on May 27, 2020

    @pradn
    pradn
    on May 27, 2020
    Contributor
    More actions

    will_accept is unnecessary, and partially duplicates the checks done in thread.Batch.publish. We should just incorporate it into publish().

    I don't think people rely on being able to override Batch. We have made a bunch of changes to Batch that they would have to keep up with, so it's not advisable anyway. So it should be fine to just modify the interface without deprecation.

  4. pradn
    closed this as completedin #108on Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @IlyaFaer
    IlyaFaer

Labels

api: pubsubIssues related to the googleapis/python-pubsub API.type: cleanupAn internal cleanup or hygiene concern.

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.