@@ -212,7 +212,7 @@ def as_curl(self, endpoint, encoded_data, headers):
212
212
url = endpoint , headers = "" .join (header_list ), data = data ))
213
213
214
214
def send (self , data = None , headers = None , ttl = 0 , gcm_key = None , reg_id = None ,
215
- content_encoding = "aesgcm" , curl = False ):
215
+ content_encoding = "aesgcm" , curl = False , timeout = None ):
216
216
"""Encode and send the data to the Push Service.
217
217
218
218
:param data: A serialized block of data (see encode() ).
@@ -233,6 +233,8 @@ def send(self, data=None, headers=None, ttl=0, gcm_key=None, reg_id=None,
233
233
:type content_encoding: str
234
234
:param curl: Display output as `curl` command instead of sending
235
235
:type curl: bool
236
+ :param timeout: POST requests timeout
237
+ :type timeout: float or tuple
236
238
237
239
"""
238
240
# Encode the data.
@@ -285,15 +287,17 @@ def send(self, data=None, headers=None, ttl=0, gcm_key=None, reg_id=None,
285
287
return self .as_curl (endpoint , encoded_data , headers )
286
288
return requests .post (endpoint ,
287
289
data = encoded_data ,
288
- headers = headers )
290
+ headers = headers ,
291
+ timeout = timeout )
289
292
290
293
291
294
def webpush (subscription_info ,
292
295
data = None ,
293
296
vapid_private_key = None ,
294
297
vapid_claims = None ,
295
298
content_encoding = "aesgcm" ,
296
- curl = False ):
299
+ curl = False ,
300
+ timeout = None ):
297
301
"""
298
302
One call solution to endcode and send `data` to the endpoint
299
303
contained in `subscription_info` using optional VAPID auth headers.
@@ -330,6 +334,8 @@ def webpush(subscription_info,
330
334
:type content_encoding: str
331
335
:param curl: Return as "curl" string instead of sending
332
336
:type curl: bool
337
+ :param timeout: POST requests timeout
338
+ :type timeout: float or tuple
333
339
:return requests.Response or string
334
340
335
341
"""
@@ -354,6 +360,7 @@ def webpush(subscription_info,
354
360
vapid_headers ,
355
361
content_encoding = content_encoding ,
356
362
curl = curl ,
363
+ timeout = timeout ,
357
364
)
358
365
if not curl and result .status_code > 202 :
359
366
raise WebPushException ("Push failed: {}: {}" .format (
0 commit comments