@@ -305,6 +305,7 @@ def apns_send_bulk_message(
305305 mutable_content : Optional [bool ] = False ,
306306 category : Optional [str ] = None ,
307307 err_func : Optional [ErrFunc ] = None ,
308+ timeout : Optional [int ] = None ,
308309) -> Dict [str , str ]:
309310 """
310311 Sends an APNS notification to one or more registration_ids.
@@ -326,7 +327,11 @@ def apns_send_bulk_message(
326327 Notification Content Extension or UNNotificationCategory configuration.
327328 It allows the app to display custom actions with the notification.
328329 :param content_available: If True the `content-available` flag will be set to 1, allowing the app to be woken up in the background
330+ :param timeout: Timeout in seconds for each notification send operation
329331 """
332+ if not timeout :
333+ timeout = get_manager ().get_apns_error_timeout (application_id )
334+
330335 try :
331336 topic = get_manager ().get_apns_topic (application_id )
332337 results : Dict [str , str ] = {}
@@ -351,6 +356,7 @@ def apns_send_bulk_message(
351356 mutable_content = mutable_content ,
352357 category = category ,
353358 err_func = err_func ,
359+ timeout = timeout ,
354360 )
355361 )
356362
@@ -386,6 +392,7 @@ def apns_send_bulk_message(
386392
387393async def _send_bulk_request (
388394 registration_ids : list [str ],
395+ timeout : int ,
389396 alert : Union [str , Alert ],
390397 application_id : Optional [str ] = None ,
391398 creds : Optional [Credentials ] = None ,
@@ -432,16 +439,17 @@ async def _send_bulk_request(
432439 for registration_id in registration_ids
433440 ]
434441
435- send_requests = [_send_request (client , request ) for request in requests ]
442+ send_requests = [_send_request (client , request , timeout ) for request in requests ]
436443 return await asyncio .gather (* send_requests )
437444
438445
439446async def _send_request (
440447 apns : APNs ,
441448 request : NotificationRequest ,
449+ timeout : int ,
442450) -> Tuple [str , NotificationResult ]:
443451 try :
444- res = await asyncio .wait_for (apns .send_notification (request ), timeout = 1 )
452+ res = await asyncio .wait_for (apns .send_notification (request ), timeout = timeout )
445453 return request .device_token , res
446454
447455 except asyncio .TimeoutError :
0 commit comments