1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Added timeout to osu requests

This commit is contained in:
Steffo 2017-02-20 11:16:04 +01:00
parent 1dc5731ead
commit 348c880793

3
osu.py
View file

@ -1,5 +1,6 @@
import asyncio import asyncio
import requests import requests
import functools
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
# Load Osu API key from the osutoken.txt file # Load Osu API key from the osutoken.txt file
@ -15,7 +16,7 @@ async def get_user(user, mode=0):
"u": user "u": user
} }
# Get the data # Get the data
r = await loop.run_in_executor(None, requests.get, 'https://osu.ppy.sh/api/get_user?k={k}&m={m}&u={u}'.format(**params)) r = await loop.run_in_executor(None, functools.partial(requests.get, timeout=6.1) 'https://osu.ppy.sh/api/get_user?k={k}&m={m}&u={u}'.format(**params))
if r.status_code == 200: if r.status_code == 200:
return r.json()[0] return r.json()[0]
else: else: