#random aiohttp warning/error

1 messages · Page 1 of 1 (latest)

cloud bloom
#

ignore it

#

that happens if you use .close()

hazy haven
#

If it appear every second it’s an issue in ur code

#

Since when does it occur ?

#

What did u change into ur code today ?

marble dew
#

please dont use requests

#

not async

#

it'll block your entire bot while it does its thing

#

use aiohttp instead

hazy haven
#

.tag request

molten jettyBOT
#

Tag not found.

Did you mean...
requests
norequests

hazy haven
#

.tag requests

molten jettyBOT
#

Why you should not use the requests library for your bot
requests is a popular HTTP library for Python. It is however not a good option for Discord bots, since it is not async and blocking.

This essentially means that your bot will not be able to execute any code at all while a request is happening. Since requests usually take a few seconds to complete, this can have a detrimental effect on your bot's performance. E.g if a user executes a command that performs a request taking 5 seconds to complete, no one else will be able to use your bot for those 5 seconds.

Please look at using a HTTP library that has async support, such as aiohttp or httpx

cloud bloom
#

it would do the same a sleep

#

and it will block your bot

#

after it, it can crash, random errors

#

and many other problems

#

random shutdowns

#

you can use requests with a new loop

#

.rie

molten jettyBOT
#

You can run blocking code (such as PIL/Pillow) in an executor to run it in a separate thread: ```py
def my_blocking_func(*args):
...

@bot.command()
async def test_command(ctx):
ret = await bot.loop.run_in_executor(my_blocking_func, 'put', 'args', 'here')``` See the python documentation for more info.

cloud bloom
#

else you have to use something like aiohttp

hazy haven
#

Ça va te bloquer tout ton bot, pas juste ne pas faire la suite

marble dew
#

that's not how async works....

#

please learn python

marble dew
#

no, that isnt how async works

#

async stuff doesn't just continue to the next line while the previous line isn't even done

#

that would make no sense