3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-26 04:32: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.users = []
self.internal = internal self.internal = internal
self.name = name.lower() self.name = name.lower()
self.has_bursted = False
def __repr__(self): def __repr__(self):
return repr(self.__dict__) return repr(self.__dict__)

View File

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

View File

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

View File

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