Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions obd/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@ def running(self):
return self.__running


def main_loop(self):
""" Starts the async update loop without using thread """
if not self.is_connected():
logger.info("Async thread not started because no connection was made")
return

if len(self.__commands) == 0:
logger.info("Async thread not started because no commands were registered")
return

if self.__thread is None:
logger.info("Starting async thread")
self.__running = True
try:
self.__thread = Async.main_loop
self.run()
except Exception as e:
logger.info('Exception %s' % str(e))
if self.__thread is not None:
assert self.__thread == Async.main_loop
self.__running = False
self.__thread = None


def start(self):
""" Starts the async update loop """
if not self.is_connected():
Expand Down