Don't launch timer thread before bot launch
This commit is contained in:
parent
30ec912162
commit
5646850df1
@ -57,7 +57,7 @@ class Bot(threading.Thread):
|
||||
sys.version_info.major, sys.version_info.minor, sys.version_info.micro)
|
||||
|
||||
self.debug = debug
|
||||
self.stop = None
|
||||
self.stop = True
|
||||
|
||||
# External IP for accessing this bot
|
||||
import ipaddress
|
||||
@ -164,8 +164,13 @@ class Bot(threading.Thread):
|
||||
|
||||
self._poll.register(sync_queue._reader, select.POLLIN | select.POLLPRI)
|
||||
|
||||
logger.info("Starting main loop")
|
||||
|
||||
self.stop = False
|
||||
|
||||
# Relaunch events
|
||||
self._update_event_timer()
|
||||
|
||||
logger.info("Starting main loop")
|
||||
while not self.stop:
|
||||
for fd, flag in self._poll.poll():
|
||||
# Handle internal socket passing orders
|
||||
@ -256,10 +261,6 @@ class Bot(threading.Thread):
|
||||
module_src -- The module to which the event is attached to
|
||||
"""
|
||||
|
||||
if hasattr(self, "stop") and self.stop:
|
||||
logger.warn("The bot is stopped, can't register new events")
|
||||
return
|
||||
|
||||
import uuid
|
||||
|
||||
# Generate the event id if no given
|
||||
@ -286,7 +287,7 @@ class Bot(threading.Thread):
|
||||
break
|
||||
self.events.insert(i, evt)
|
||||
|
||||
if i == 0:
|
||||
if i == 0 and not self.stop:
|
||||
# First event changed, reset timer
|
||||
self._update_event_timer()
|
||||
if len(self.events) <= 0 or self.events[i] != evt:
|
||||
@ -417,10 +418,6 @@ class Bot(threading.Thread):
|
||||
old one before"""
|
||||
module_name = module.__spec__.name if hasattr(module, "__spec__") else module.__name__
|
||||
|
||||
if hasattr(self, "stop") and self.stop:
|
||||
logger.warn("The bot is stopped, can't register new modules")
|
||||
return
|
||||
|
||||
# Check if the module already exists
|
||||
if module_name in self.modules:
|
||||
self.unload_module(module_name)
|
||||
|
Loading…
Reference in New Issue
Block a user