Ensure timeout in requests

This commit is contained in:
Eliot Berriot 2018-04-08 13:33:36 +02:00
parent b8c7e960c3
commit 206ae296b6
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
4 changed files with 5 additions and 1 deletions

View file

@ -31,6 +31,7 @@ def remove_tags(text):
def get_actor_data(actor_url):
response = session.get_session().get(
actor_url,
timeout=5,
headers={
'Accept': 'application/activity+json',
}
@ -42,6 +43,7 @@ def get_actor_data(actor_url):
raise ValueError(
'Invalid actor payload: {}'.format(response.text))
def get_actor(actor_url):
data = get_actor_data(actor_url)
serializer = serializers.ActorSerializer(data=data)