forked from M-Labs/thermostat
Correct exception catching
asyncio.Task.result() is simply going to throw the exception in asyncio.Task.exception(), there is no need to manually throw it.
This commit is contained in:
parent
6388aac023
commit
759b9e57a1
@ -40,19 +40,17 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
self.task = asyncio.create_task(self.update_params())
|
self.task = asyncio.create_task(self.update_params())
|
||||||
while True:
|
while True:
|
||||||
if self.task.done():
|
if self.task.done():
|
||||||
if self.task.exception() is not None:
|
try:
|
||||||
try:
|
_ = self.task.result()
|
||||||
raise self.task.exception()
|
except (
|
||||||
except (
|
Exception,
|
||||||
Exception,
|
TimeoutError,
|
||||||
TimeoutError,
|
asyncio.exceptions.TimeoutError,
|
||||||
asyncio.exceptions.TimeoutError,
|
):
|
||||||
):
|
logging.error(
|
||||||
logging.error(
|
"Encountered an error while updating parameter tree.",
|
||||||
"Encountered an error while updating parameter tree.",
|
exc_info=True,
|
||||||
exc_info=True,
|
)
|
||||||
)
|
|
||||||
_ = self.task.result()
|
|
||||||
self.task = asyncio.create_task(self.update_params())
|
self.task = asyncio.create_task(self.update_params())
|
||||||
await asyncio.sleep(self._update_s)
|
await asyncio.sleep(self._update_s)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user