Skip to content

basic_publish allows str type #8

@baodrate

Description

@baodrate

basic_publish's body parameter, e.g.:

def basic_publish(
self,
exchange: str,
routing_key: str,
body: bytes,
properties: Optional[spec.BasicProperties] = ...,
mandatory: bool = ...,
) -> None: ...

or

def basic_publish(
self,
exchange: str,
routing_key: str,
body: bytes,
properties: Optional[spec.BasicProperties] = ...,
mandatory: bool = ...,
) -> None: ...

allows a str argument, per pika code:

   def basic_publish(self,
                     exchange,
                     routing_key,
                     body,
                     properties=None,
                     mandatory=False):
       """Publish to the channel with the given exchange, routing key and body.
       For more information on basic_publish and what the parameters do, see:

       http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish

       :param str exchange: The exchange to publish to
       :param str routing_key: The routing key to bind on
       :param bytes body: The message body
       :param pika.spec.BasicProperties properties: Basic.properties
       :param bool mandatory: The mandatory flag

       """
       self._raise_if_not_open()
       if isinstance(body, unicode_type):
           body = body.encode('utf-8')
       properties = properties or spec.BasicProperties()
       ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions