@@ -212,7 +212,7 @@ def as_curl(self, endpoint, encoded_data, headers):
212212 url = endpoint , headers = "" .join (header_list ), data = data ))
213213
214214 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 ):
216216 """Encode and send the data to the Push Service.
217217
218218 :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,
233233 :type content_encoding: str
234234 :param curl: Display output as `curl` command instead of sending
235235 :type curl: bool
236+ :param timeout: POST requests timeout
237+ :type timeout: float or tuple
236238
237239 """
238240 # Encode the data.
@@ -285,15 +287,17 @@ def send(self, data=None, headers=None, ttl=0, gcm_key=None, reg_id=None,
285287 return self .as_curl (endpoint , encoded_data , headers )
286288 return requests .post (endpoint ,
287289 data = encoded_data ,
288- headers = headers )
290+ headers = headers ,
291+ timeout = timeout )
289292
290293
291294def webpush (subscription_info ,
292295 data = None ,
293296 vapid_private_key = None ,
294297 vapid_claims = None ,
295298 content_encoding = "aesgcm" ,
296- curl = False ):
299+ curl = False ,
300+ timeout = None ):
297301 """
298302 One call solution to endcode and send `data` to the endpoint
299303 contained in `subscription_info` using optional VAPID auth headers.
@@ -330,6 +334,8 @@ def webpush(subscription_info,
330334 :type content_encoding: str
331335 :param curl: Return as "curl" string instead of sending
332336 :type curl: bool
337+ :param timeout: POST requests timeout
338+ :type timeout: float or tuple
333339 :return requests.Response or string
334340
335341 """
@@ -354,6 +360,7 @@ def webpush(subscription_info,
354360 vapid_headers ,
355361 content_encoding = content_encoding ,
356362 curl = curl ,
363+ timeout = timeout ,
357364 )
358365 if not curl and result .status_code > 202 :
359366 raise WebPushException ("Push failed: {}: {}" .format (
0 commit comments