Skip to content

Commit

Permalink
check if self._thread is None in is_running() and quit()
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Sep 20, 2019
1 parent e25fcdd commit c1fd537
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions msl/qt/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ def add_callback(self, callback):

def is_running(self):
""":class:`bool`: Whether the thread is running."""
if self._thread is None:
return False
return self._thread.isRunning()

def quit(self):
"""Tells the thread's event loop to exit."""
if self._thread is None:
return
self._thread.quit()

def remove_callback(self, callback):
Expand All @@ -105,7 +109,7 @@ def remove_callback(self, callback):
try:
self._callbacks.remove(callback)
except ValueError:
logger.warning('callback "{}" was not removed from "{}"'.format(
logger.warning('callback {!r} was not removed from {!r}'.format(
callback.__name__, self.__class__.__name__))

def start(self, *args, **kwargs):
Expand Down Expand Up @@ -137,7 +141,7 @@ def wait(self, milliseconds=None):
----------
milliseconds : :class:`int`, optional
The number of milliseconds to wait before a timeout occurs.
If :obj:`None` then :meth:`wait` will never timeout and the
If :data:`None` then :meth:`wait` will never timeout and the
thread must return from its ``run`` method.
Returns
Expand Down

0 comments on commit c1fd537

Please sign in to comment.