Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch datatype of consumer_tag in Basic.ConsumeOk #12

Open
baodrate opened this issue Mar 21, 2022 · 1 comment · May be fixed by #13
Open

Mismatch datatype of consumer_tag in Basic.ConsumeOk #12

baodrate opened this issue Mar 21, 2022 · 1 comment · May be fixed by #13

Comments

@baodrate
Copy link
Owner

This is how Pika generate consumer tag (line 336 in pika/channel.py):

def _generate_consumer_tag(self):
    """Generate a consumer tag

    NOTE: this protected method may be called by derived classes

    :returns: consumer tag
    :rtype: str

    """
    return 'ctag%i.%s' % (self.channel_number, uuid.uuid4().hex)

By default, the consumer tag is a str, which contradicts the data type of ConsumeOk.consume_tag in the stub file (line 1415 in pika-stubs/spec.pyi):

class ConsumeOk(amqp_object.Method):
    ...
    consumer_tag: Optional[int] = ...
    ...

So, is this an error on pika-stubs?

Disclaimer: I haven't read the AMQP specification. (Edit: I'm reading it, but not thoroughly)


copied from hahow/pika-stubs#10 (originally by gytqby)

@baodrate
Copy link
Owner Author

rabbitmq's amqp reference indicates consumer-tag should always be a str

currently, consumer_tag is inconsistent. it is str for the responses:

  • Basic.Consume
  • Basic.Deliver

but int for:

  • Basic.ConsumeOk
  • Basic.Cancel
  • Basic.CancelOk

@baodrate baodrate linked a pull request Mar 21, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant