Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add note to docs about using sched with @rate #825

Merged
merged 1 commit into from
Jul 3, 2015
Merged

Add note to docs about using sched with @rate #825

merged 1 commit into from
Jul 3, 2015

Conversation

dgw
Copy link
Member

@dgw dgw commented Jun 25, 2015

No description provided.

embolalia added a commit that referenced this pull request Jul 3, 2015
Add note to docs about using sched with @Rate
@embolalia embolalia merged commit a97c4b2 into sopel-irc:master Jul 3, 2015
@dgw dgw deleted the rate-caveat branch July 16, 2015 07:26
@dgw
Copy link
Member Author

dgw commented Sep 2, 2024

I'm revisiting this from the future to note that it was spurred by behavior described in #824.

This note seems not to apply any more after the rule-system rewrite for 7.x; the callable's start time is now used for rate-limiting if it hasn't completed yet:

@property
def last_time(self) -> Optional[datetime.datetime]:
"""Last recorded start/end time for the associated rule."""
# detect if we just started something or if it ended
if (self.started_at and self.ended_at) and (self.started_at < self.ended_at):
return self.ended_at
return self.started_at

Quick and dirty plugin to test sched's behavior with rate-limiting in 8.0
import sched
import time

from sopel import plugin


s = sched.scheduler(time.time, time.sleep)


@plugin.rate(60)
@plugin.command('testrate')
def rate_limited(bot, trigger):
    s.enter(30, 2, bot.say, argument=('hi',))
    s.run()

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants