dirty fix for exchange rates

This commit is contained in:
Tiago vasconcelos 2021-10-22 11:00:15 +01:00
parent a6de60aab7
commit e532ce1971

View File

@ -1,7 +1,8 @@
import asyncio
import httpx
from typing import Callable, NamedTuple
import httpx
currencies = {
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
@ -244,14 +245,15 @@ async def btc_price(currency: str) -> float:
r.raise_for_status()
data = r.json()
rate = float(provider.getter(data, replacements))
rates.append(rate)
await send_channel.put(rate)
except Exception:
await send_channel.put(None)
# asyncio.create_task(controller, nursery)
for key, provider in exchange_rate_providers.items():
await fetch_price(key, provider)
asyncio.create_task(fetch_price(key, provider))
if not rates:
return 9999999999