From 0f58f6f0b66f0533f83dc74e184270a2db28ab90 Mon Sep 17 00:00:00 2001 From: Edward Wignall Date: Fri, 14 Oct 2022 14:45:12 +0100 Subject: [PATCH] Added Timeout Parameter --- publisher/async.py | 5 +++-- publisher/sync.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/publisher/async.py b/publisher/async.py index 632dc4b..0bdddec 100644 --- a/publisher/async.py +++ b/publisher/async.py @@ -11,7 +11,7 @@ class AsyncPublisher(Publisher): - def publish(self, message: Message) -> str: + def publish(self, message: Message, timeout: float) -> str: # check the parameters of the request self._check_parameters(message) @@ -19,7 +19,8 @@ def publish(self, message: Message) -> str: request = grequests.post( self.mercure_hub, data=Publisher._get_form_data(message), - headers=self._get_request_headers() + headers=self._get_request_headers(), + timeout=timeout ) response = grequests.map([request]).pop(0) diff --git a/publisher/sync.py b/publisher/sync.py index 9cc487c..890f0af 100644 --- a/publisher/sync.py +++ b/publisher/sync.py @@ -11,7 +11,7 @@ class SyncPublisher(Publisher): - def publish(self, message: Message) -> str: + def publish(self, message: Message, timeout: float) -> str: # check the parameters of the request self._check_parameters(message) @@ -19,7 +19,8 @@ def publish(self, message: Message) -> str: response = requests.post( self.mercure_hub, Publisher._get_form_data(message), - headers=self._get_request_headers() + headers=self._get_request_headers(), + timeout=timeout ) if response.status_code == 403: