@@ -58,7 +58,7 @@ def _create_auth(self, username=None, password=None): # pylint: disable=no-self
5858 return authentication .SASLPlain (
5959 self .address .hostname , username , password , http_proxy = self .http_proxy )
6060 return authentication .SASTokenAsync .from_shared_access_key (
61- self .auth_uri , username , password , timeout = 60 , http_proxy = self .http_proxy )
61+ self .auth_uri , username , password , timeout = self . auth_timeout , http_proxy = self .http_proxy )
6262
6363 async def _close_clients_async (self ):
6464 """
@@ -77,8 +77,9 @@ async def _start_client_async(self, client):
7777 try :
7878 await client .open_async ()
7979 except Exception as exp : # pylint: disable=broad-except
80- log .info ("Encountered error while starting handler: {}" . format ( exp ) )
80+ log .info ("Encountered error while starting handler: %r" , exp )
8181 await client .close_async (exception = exp )
82+ log .info ("Finished closing failed handler" )
8283
8384 async def _handle_redirect (self , redirects ):
8485 if len (redirects ) != len (self .clients ):
@@ -104,17 +105,17 @@ async def run_async(self):
104105
105106 :rtype: list[~azure.eventhub.common.EventHubError]
106107 """
107- log .info ("{} : Starting {} clients" . format ( self .container_id , len (self .clients ) ))
108+ log .info ("%r : Starting %r clients" , self .container_id , len (self .clients ))
108109 tasks = [self ._start_client_async (c ) for c in self .clients ]
109110 try :
110111 await asyncio .gather (* tasks )
111112 redirects = [c .redirected for c in self .clients if c .redirected ]
112113 failed = [c .error for c in self .clients if c .error ]
113114 if failed and len (failed ) == len (self .clients ):
114- log .warning ("{} : All clients failed to start." . format ( self .container_id ) )
115+ log .warning ("%r : All clients failed to start." , self .container_id )
115116 raise failed [0 ]
116117 elif failed :
117- log .warning ("{}: {} clients failed to start." . format ( self .container_id , len (failed ) ))
118+ log .warning ("%r: %r clients failed to start." , self .container_id , len (failed ))
118119 elif redirects :
119120 await self ._handle_redirect (redirects )
120121 except EventHubError :
@@ -129,7 +130,7 @@ async def stop_async(self):
129130 """
130131 Stop the EventHubClient and all its Sender/Receiver clients.
131132 """
132- log .info ("{} : Stopping {} clients" . format ( self .container_id , len (self .clients ) ))
133+ log .info ("%r : Stopping %r clients" , self .container_id , len (self .clients ))
133134 self .stopped = True
134135 await self ._close_clients_async ()
135136
@@ -182,7 +183,7 @@ def add_async_receiver(
182183 :operation: An optional operation to be appended to the hostname in the source URL.
183184 The value must start with `/` character.
184185 :type operation: str
185- :rtype: ~azure.eventhub._async .receiver_async.ReceiverAsync
186+ :rtype: ~azure.eventhub.async_ops .receiver_async.ReceiverAsync
186187 """
187188 path = self .address .path + operation if operation else self .address .path
188189 source_url = "amqps://{}{}/ConsumerGroups/{}/Partitions/{}" .format (
@@ -213,7 +214,7 @@ def add_async_epoch_receiver(
213214 :operation: An optional operation to be appended to the hostname in the source URL.
214215 The value must start with `/` character.
215216 :type operation: str
216- :rtype: ~azure.eventhub._async .receiver_async.ReceiverAsync
217+ :rtype: ~azure.eventhub.async_ops .receiver_async.ReceiverAsync
217218 """
218219 path = self .address .path + operation if operation else self .address .path
219220 source_url = "amqps://{}{}/ConsumerGroups/{}/Partitions/{}" .format (
@@ -224,7 +225,9 @@ def add_async_epoch_receiver(
224225 self .clients .append (handler )
225226 return handler
226227
227- def add_async_sender (self , partition = None , operation = None , keep_alive = 30 , auto_reconnect = True , loop = None ):
228+ def add_async_sender (
229+ self , partition = None , operation = None , send_timeout = 60 ,
230+ keep_alive = 30 , auto_reconnect = True , loop = None ):
228231 """
229232 Add an async sender to the client to send ~azure.eventhub.common.EventData object
230233 to an EventHub.
@@ -236,13 +239,23 @@ def add_async_sender(self, partition=None, operation=None, keep_alive=30, auto_r
236239 :operation: An optional operation to be appended to the hostname in the target URL.
237240 The value must start with `/` character.
238241 :type operation: str
239- :rtype: ~azure.eventhub._async.sender_async.SenderAsync
242+ :param send_timeout: The timeout in seconds for an individual event to be sent from the time that it is
243+ queued. Default value is 60 seconds. If set to 0, there will be no timeout.
244+ :type send_timeout: int
245+ :param keep_alive: The time interval in seconds between pinging the connection to keep it alive during
246+ periods of inactivity. The default value is 30 seconds. If set to `None`, the connection will not
247+ be pinged.
248+ :type keep_alive: int
249+ :param auto_reconnect: Whether to automatically reconnect the sender if a retryable error occurs.
250+ Default value is `True`.
251+ :type auto_reconnect: bool
252+ :rtype: ~azure.eventhub.async_ops.sender_async.SenderAsync
240253 """
241254 target = "amqps://{}{}" .format (self .address .hostname , self .address .path )
242255 if operation :
243256 target = target + operation
244257 handler = AsyncSender (
245- self , target , partition = partition , keep_alive = keep_alive ,
258+ self , target , partition = partition , send_timeout = send_timeout , keep_alive = keep_alive ,
246259 auto_reconnect = auto_reconnect , loop = loop )
247260 self .clients .append (handler )
248261 return handler
0 commit comments