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