nithp | - View NITH result
kandi X-RAY | nithp Summary
kandi X-RAY | nithp Summary
View NITH result live.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Search for results
- Return all student data
- Validate and set defaults
- Read a single roll
- Run a SQL query
- Decorator to compress the response
- Return a list of Subject objects
- Read all subject information
nithp Key Features
nithp Examples and Code Snippets
Community Discussions
Trending Discussions on nithp
QUESTION
I am making a car based discord bot and I want to add power ups , one of them include Nitrous . Nitrous will increase your power for 30 minutes and then revert back to normal but for some reason it forgets the timer and permanently increases the user's power. I tried using await asyncio.sleep(1800)
but it doesn't seem to work as you can see (1800 seconds is 30 minutes) . No errors are shown too.
This is the code...
...ANSWER
Answered 2021-Mar-10 at 18:51You have discovered one of the big issues involved with using any sort of sleep function to manage future events. The way asyncio.sleep
works is that it registers a future. A future is like a placeholder for a function that hasn't returned yet. You don't have to wait for the function until you actually want to read the result but the function is still processing in the background. Futures are one of the foundational elements of asynchronous processing.
Technically asyncio.sleep
should work in this context. I'm not sure entirely what is happening but most likely the discord.py
library has some sort of manager that drops these futures if they're suspended for more than a certain amount of time. If I find out more about this then I'll edit this answer.
The long and the short of it is that you should not use sleep calls for long events like this one. Instead, you should create a global (or guild-level) database and have a looping task that reads from that database and calls a function that runs all the code below the asyncio.sleep
. You could do this by creating a dictionary that stores when a users nitro will finish along with some other information like the author and channel.
You can find out more about tasks in the discord.py library here
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nithp
Clone the repository
Create the virtual environment and install dependencies
Enter into shell
Run the application
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page