#๐ How can I optimise my api wrapper library for use with discord.py?
51 messages ยท Page 1 of 1 (latest)
@urban hollow
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
optimise it by making it asynchronous
this library is an asynchronous way to make requests
sleep's should be replaced with asyncio.sleep
asynchronous code just lets your computer switch between what code its running
yes I saw that
so the whole simplicity would kinda go away
it would no longer be a super simple as possible library
whats going to happen is that if you ever hit a ratelimit your bot will become completely unresponsive for retry-after seconds
every single command, everything
i do plan on adding a leaky bucket algo so that never happens
A what?
but if im rate limited by the riot api surely ill have to wait for the timer anyway
just have it be asynchronous
the point of asynchronous code is that
you can run other code while waiting
for example, one command invocation might be waiting for the riot api call
ohhh u mean the whole bot will hang and wait
right right
that's what asynchronous programming is for
cool
and its really useful in network IO
because networking consists of lots of waiting
you are waiting for the response to your request
so why not run other code during that time
you could try both but it could increase the complexity
yeah i really want it to stay simple as possible
hard choice, i dont know if i should do one or both
if it's intended for discord bots you def want async
i might make it just async only then
generally it'll be useful that way for most applications
and its not like you wouldn't be able to use it standalone
for example if you just wanted a program that makes one call you could chuck it in an async function and asyncio.run it
i guess im just thinking how many users does that exclude
shouldn't really exclude any users
just the newer devs that dont know how to do that i guess
that can be your quickstart example
i also badly need docs
look at the getting started here
ive used aiohttp a bit but yeah i defo will look into it
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.