diff --git a/tasks.py b/tasks.py index d5371a53..3146be57 100644 --- a/tasks.py +++ b/tasks.py @@ -24,6 +24,8 @@ # Used as a sentinel value in the webmention endpoint cache NO_ENDPOINT = 'NONE' +WEBMENTION_SEND_TIMEOUT = datetime.timedelta(seconds=30) + def is_quote_mention(activity, source): obj = activity.get('object') or activity @@ -598,8 +600,8 @@ def do_send_webmentions(self): if endpoint and endpoint != NO_ENDPOINT: logger.info('Sending...') - resp = webmention.send(endpoint, source_url, target, timeout=999, - headers=headers) + resp = webmention.send(endpoint, source_url, target, headers=headers, + timeout=WEBMENTION_SEND_TIMEOUT.total_seconds()) logger.info(f'Sent! {resp}') self.record_source_webmention(endpoint, target) self.entity.sent.append(target) diff --git a/tests/test_tasks.py b/tests/test_tasks.py index 2180cda5..bd98f489 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -1479,8 +1479,9 @@ def expect_webmention(self, source_url=None, target='http://target1/post/url', call = self.expect_requests_post(endpoint, data={ 'source': source_url, 'target': target, - }, status_code=send_status, allow_redirects=False, timeout=999, - **kwargs).InAnyOrder() + }, status_code=send_status, allow_redirects=False, + timeout=WEBMENTION_SEND_TIMEOUT.total_seconds(), **kwargs, + ).InAnyOrder() return call @@ -1696,7 +1697,7 @@ def test_webmention_post_accept_header(self): response_headers={'Link': '; rel=webmention'}) self.expect_requests_post( - 'http://my/endpoint', timeout=999, + 'http://my/endpoint', timeout=WEBMENTION_SEND_TIMEOUT.total_seconds(), data={'source': 'http://localhost/comment/fake/0123456789/a/1_2_a', 'target': 'http://target1/post/url'}, allow_redirects=False, headers={'Accept': '*/*'})