mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 12:12:53 +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:
parent
a7a5688e69
commit
67f5bbba4b
@ -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__)
|
||||||
|
|
||||||
|
1
main.py
1
main.py
@ -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)
|
||||||
|
|
||||||
|
@ -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")
|
||||||
|
2
utils.py
2
utils.py
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user