kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Ensure timeout in requests
rodzic
b8c7e960c3
commit
206ae296b6
|
@ -73,6 +73,7 @@ def deliver(activity, on_behalf_of, to=[]):
|
||||||
auth=auth,
|
auth=auth,
|
||||||
json=activity,
|
json=activity,
|
||||||
url=recipient_actor.inbox_url,
|
url=recipient_actor.inbox_url,
|
||||||
|
timeout=5,
|
||||||
headers={
|
headers={
|
||||||
'Content-Type': 'application/activity+json'
|
'Content-Type': 'application/activity+json'
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ def remove_tags(text):
|
||||||
def get_actor_data(actor_url):
|
def get_actor_data(actor_url):
|
||||||
response = session.get_session().get(
|
response = session.get_session().get(
|
||||||
actor_url,
|
actor_url,
|
||||||
|
timeout=5,
|
||||||
headers={
|
headers={
|
||||||
'Accept': 'application/activity+json',
|
'Accept': 'application/activity+json',
|
||||||
}
|
}
|
||||||
|
@ -42,6 +43,7 @@ def get_actor_data(actor_url):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'Invalid actor payload: {}'.format(response.text))
|
'Invalid actor payload: {}'.format(response.text))
|
||||||
|
|
||||||
|
|
||||||
def get_actor(actor_url):
|
def get_actor(actor_url):
|
||||||
data = get_actor_data(actor_url)
|
data = get_actor_data(actor_url)
|
||||||
serializer = serializers.ActorSerializer(data=data)
|
serializer = serializers.ActorSerializer(data=data)
|
||||||
|
|
|
@ -47,7 +47,7 @@ def get_resource(resource_string):
|
||||||
username, hostname = clean_acct(resource, ensure_local=False)
|
username, hostname = clean_acct(resource, ensure_local=False)
|
||||||
url = 'https://{}/.well-known/webfinger?resource={}'.format(
|
url = 'https://{}/.well-known/webfinger?resource={}'.format(
|
||||||
hostname, resource_string)
|
hostname, resource_string)
|
||||||
response = session.get_session().get(url)
|
response = session.get_session().get(url, timeout=5)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
serializer = serializers.ActorWebfingerSerializer(data=response.json())
|
serializer = serializers.ActorWebfingerSerializer(data=response.json())
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
|
|
|
@ -218,6 +218,7 @@ class TrackFileViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
library_track.audio_url,
|
library_track.audio_url,
|
||||||
auth=auth,
|
auth=auth,
|
||||||
stream=True,
|
stream=True,
|
||||||
|
timeout=20,
|
||||||
headers={
|
headers={
|
||||||
'Content-Type': 'application/activity+json'
|
'Content-Type': 'application/activity+json'
|
||||||
})
|
})
|
||||||
|
|
Ładowanie…
Reference in New Issue