3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 11:42:51 +01:00

add a utils.started threaded trigger, so plugins can ACTUALLY wait until all Irc objects have been initialized to do their work

This commit is contained in:
James Lu 2015-07-13 16:07:55 -07:00
parent a7a5688e69
commit 67f5bbba4b
4 changed files with 9 additions and 2 deletions

View File

@ -36,6 +36,7 @@ class IrcServer():
self.users = []
self.internal = internal
self.name = name.lower()
self.has_bursted = False
def __repr__(self):
return repr(self.__dict__)

View File

@ -130,5 +130,6 @@ if __name__ == '__main__':
sys.exit(2)
else:
utils.networkobjects[network] = Irc(network, proto, conf.conf)
utils.started.set()
log.info("loaded plugins: %s", utils.plugins)

View File

@ -295,6 +295,7 @@ def delink(irc, source, args):
utils.msg(irc, source, 'Done.')
def initializeAll(irc):
utils.started.wait()
for chanpair, entrydata in db.items():
network, channel = chanpair
initializeChannel(irc, channel)
@ -310,9 +311,10 @@ def main():
thread = threading.Thread(target=scheduler.run)
thread.daemon = True
thread.start()
'''
for ircobj in utils.networkobjects.values():
initializeAll(irc)
'''
# Same goes for all the other initialization stuff; we only
# want it to happen once.
for network, ircobj in utils.networkobjects.items():
@ -321,5 +323,6 @@ def main():
'''
def handle_endburst(irc, numeric, command, args):
initializeAll(irc)
thread = threading.Thread(target=initializeAll, args=(irc,))
thread.start()
utils.add_hook(handle_endburst, "ENDBURST")

View File

@ -1,6 +1,7 @@
import string
import re
from collections import defaultdict
import threading
from log import log
@ -11,6 +12,7 @@ command_hooks = defaultdict(list)
networkobjects = {}
schedulers = {}
plugins = []
started = threading.Event()
class TS6UIDGenerator():
"""TS6 UID Generator module, adapted from InspIRCd source