1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 21:02:38 +00:00

Change aiohttp session to be global instead of localized

This commit is contained in:
Myned 2019-09-29 23:58:35 -04:00
parent bf7e75b0bd
commit e399050bd0
No known key found for this signature in database
GPG key ID: BC58C09870A63E59

View file

@ -81,10 +81,12 @@ cogs = {}
color = d.Color(0x1A1A1A) color = d.Color(0x1A1A1A)
last_commands = {} last_commands = {}
asession = aiohttp.ClientSession()
async def fetch(url, *, params={}, json=False, response=False, text=False): async def fetch(url, *, params={}, json=False, response=False, text=False):
async with aiohttp.ClientSession() as session: async with asession.get(url, params=params, headers={
async with session.get(url, params=params, headers={'User-Agent': 'Myned/Modufur'}, ssl=False) as r: 'User-Agent': 'Myned/Modufur (https://github.com/Myned/Modufur)'}, ssl=False) as r:
if json: if json:
return await r.json() return await r.json()
elif response: elif response: