make query_database to use async httpx
This commit is contained in:
parent
30cfae3c2f
commit
35e0757096
1 changed files with 3 additions and 8 deletions
|
@ -128,7 +128,6 @@ async def query_playhead():
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
response = await client.get(head_url)
|
response = await client.get(head_url)
|
||||||
playhead = response.json()
|
playhead = response.json()
|
||||||
logger_discord.info(f'Querying playhead at {head_url}')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger_discord.error('Cannot connect to the playhead!')
|
logger_discord.error('Cannot connect to the playhead!')
|
||||||
logger_discord.error(e)
|
logger_discord.error(e)
|
||||||
|
@ -139,13 +138,9 @@ async def query_database():
|
||||||
global database
|
global database
|
||||||
db_url = f'https://{scheduler_hostname}/database'
|
db_url = f'https://{scheduler_hostname}/database'
|
||||||
try:
|
try:
|
||||||
if requests.get(db_url).status_code == 200:
|
async with httpx.AsyncClient() as client:
|
||||||
response = requests.get(db_url)
|
response = await client.get(db_url)
|
||||||
response.raise_for_status()
|
|
||||||
database = response.json()
|
database = response.json()
|
||||||
else:
|
|
||||||
logger_discord.error('Cannot connect to the database!')
|
|
||||||
return
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger_discord.error('Cannot connect to the database!')
|
logger_discord.error('Cannot connect to the database!')
|
||||||
logger_discord.error(e)
|
logger_discord.error(e)
|
||||||
|
|
Loading…
Add table
Reference in a new issue