move PoolHook registrations to start.py
This commit is contained in:
parent
e624292608
commit
1c792f0194
2 changed files with 9 additions and 7 deletions
|
@ -36,7 +36,7 @@ class ListLambdaPollHook(PollHook.PollHook):
|
|||
|
||||
class Bot(object):
|
||||
def __init__(self, directory, args, cache, config, database, events,
|
||||
exports, log, modules, timers, lock_file):
|
||||
exports, log, modules, timers):
|
||||
self.directory = directory
|
||||
self.args = args
|
||||
self.cache = cache
|
||||
|
@ -68,11 +68,7 @@ class Bot(object):
|
|||
self._read_thread = None
|
||||
self._write_thread = None
|
||||
|
||||
self._poll_timeouts = [] # typing.List[PollHook]
|
||||
self._poll_timeouts.append(self._timers)
|
||||
self._poll_timeouts.append(self.cache)
|
||||
self._poll_timeouts.append(lock_file)
|
||||
|
||||
self._poll_timeouts = [] # typing.List[PollHook.PollHook]
|
||||
self._poll_timeouts.append(ListLambdaPollHook(
|
||||
lambda: self.servers.values(),
|
||||
lambda server: server.until_read_timeout()))
|
||||
|
@ -84,6 +80,9 @@ class Bot(object):
|
|||
self._poll_timeouts.append(ListLambdaPollHook(
|
||||
lambda: self.servers.values(), self._throttle_timeout))
|
||||
|
||||
def add_poll_hook(self, hook: PollHook.PollHook):
|
||||
self._poll_timeouts.append(hook)
|
||||
|
||||
def _throttle_timeout(self, server: IRCServer.Server):
|
||||
if server.socket.waiting_throttled_send():
|
||||
return server.socket.send_throttle_timeout()
|
||||
|
|
5
start.py
5
start.py
|
@ -106,7 +106,10 @@ modules = ModuleManager.ModuleManager(events, exports, timers, config, log,
|
|||
module_directories)
|
||||
|
||||
bot = IRCBot.Bot(directory, args, cache, config, database, events,
|
||||
exports, log, modules, timers, lock_file)
|
||||
exports, log, modules, timers)
|
||||
bot.add_poll_hook(cache)
|
||||
bot.add_poll_hook(lock_file)
|
||||
bot.add_poll_hook(timers)
|
||||
|
||||
if args.module:
|
||||
definition = modules.find_module(args.module)
|
||||
|
|
Loading…
Reference in a new issue