async def publish(self, subject, payload,<EOL>ack_handler=None,<EOL>ack_wait=DEFAULT_ACK_WAIT,<EOL>):
stan_subject = '<STR_LIT>'.join([self._pub_prefix, '<STR_LIT:.>', subject])<EOL>guid = new_guid()<EOL>pe = protocol.PubMsg()<EOL>pe.clientID = self._client_id<EOL>pe.guid = guid<EOL>pe.subject = subject<EOL>pe.data = payload<EOL>await self._pending_pub_acks_queue.put(None)<EOL>if ack_handler is not None:<EOL><INDENT>self._pub_ack_map[guid] = ack_handler<EOL>try:<EOL><INDENT>await self._nc.publish_request(<EOL>stan_subject,<EOL>self._ack_subject,<EOL>pe.SerializeToString(),<EOL>)<EOL>return<EOL><DEDENT>except Exception as e:<EOL><INDENT>del self._pub_ack_map[guid]<EOL>raise e<EOL><DEDENT><DEDENT>else:<EOL><INDENT>future = asyncio.Future(loop=self._loop)<EOL>async def cb(pub_ack):<EOL><INDENT>nonlocal future<EOL>future.set_result(pub_ack)<EOL><DEDENT>self._pub_ack_map[guid] = cb<EOL>try:<EOL><INDENT>await self._nc.publish_request(<EOL>stan_subject,<EOL>self._ack_subject,<EOL>pe.SerializeToString(),<EOL>)<EOL>await asyncio.wait_for(future, ack_wait, loop=self._loop)<EOL>return future.result()<EOL><DEDENT>except Exception as e:<EOL><INDENT>future.cancel()<EOL>del self._pub_ack_map[guid]<EOL>raise e<EOL><DEDENT><DEDENT>
Publishes a payload onto a subject.  By default, it will block
until the message which has been published has been acked back.
An optional async handler can be publi

:param subject: Subject of the message.
:param payload: Payload of the message which wil be published.
:param ack_handler: Optional handler for async publishing.
:param ack_wait: How long in seconds to wait for an ack to be received.