From a1784924539ae38ba65528a81a24d9d0ab7dc7e9 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 8 Feb 2004 10:49:08 +0000 Subject: [PATCH] Made the interval between upkeeps configurable. --- scripts/supybot | 2 +- src/conf.py | 5 +++++ src/world.py | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/supybot b/scripts/supybot index 99115dc0c..3e9d6475f 100755 --- a/scripts/supybot +++ b/scripts/supybot @@ -64,7 +64,7 @@ def main(): import world import drivers import schedule - schedule.addPeriodicEvent(world.upkeep, 300) + world.upkeep() world.startedAt = started while world.ircs: try: diff --git a/src/conf.py b/src/conf.py index b8ef9a56f..fae5a548c 100644 --- a/src/conf.py +++ b/src/conf.py @@ -345,6 +345,11 @@ supybot.register('pingInterval', registry.Integer(120, """Determines the number of seconds between sending pings to the server, if pings are being sent to the server.""")) +supybot.register('upkeepInterval', registry.PositiveInteger(300, """Determines +the number of seconds between running the upkeep function that flushes +(commits) open databases, collects garbage, and records some useful statistics +at the debugging level.""")) + supybot.register('flush', registry.Boolean(True, """Determines whether the bot will periodically flush data and configuration files to disk. Generally, the only time you'll want to set this to False is when you want to modify those diff --git a/src/world.py b/src/world.py index 75ae95a4f..a7ff568dc 100644 --- a/src/world.py +++ b/src/world.py @@ -50,6 +50,7 @@ import log import conf import drivers import ircutils +import schedule startedAt = time.time() # Just in case it doesn't get set later. @@ -97,6 +98,7 @@ def upkeep(): log.info('%s Flushers flushed and garbage collected.', timestamp) else: log.info('%s Garbage collected.', timestamp) + schedule.addEvent(upkeep, time.time() + conf.supybot.upkeepInterval()) return collected def makeDriversDie():