#random aiohttp warning/error
1 messages · Page 1 of 1 (latest)
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 ?
please dont use requests
not async
it'll block your entire bot while it does its thing
use aiohttp instead
.tag request
Tag not found.
Did you mean...
requests
norequests
.tag requests
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
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
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.
else you have to use something like aiohttp
Ça va te bloquer tout ton bot, pas juste ne pas faire la suite