Skip to content

Commit

Permalink
drop webmention send timeout to 30s
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Feb 11, 2024
1 parent 3dd1d90 commit 7f0227d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1696,7 +1697,7 @@ def test_webmention_post_accept_header(self):
response_headers={'Link': '<http://my/endpoint>; 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': '*/*'})
Expand Down

0 comments on commit 7f0227d

Please sign in to comment.