forked from M-Labs/thermostat
Real concurrently
This commit is contained in:
parent
969a7be0cc
commit
db7cdca24c
@ -66,21 +66,32 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
||||
return await self._client.hw_rev()
|
||||
|
||||
async def update_params(self):
|
||||
fan_task = asyncio.create_task(self._client.get_fan())
|
||||
pwm_task = asyncio.create_task(self._client.get_pwm())
|
||||
pid_task = asyncio.create_task(self._client.get_pid())
|
||||
if self._poll_for_report:
|
||||
report_task = asyncio.create_task(self._client.report())
|
||||
thermistor_task = asyncio.create_task(self._client.get_steinhart_hart())
|
||||
postfilter_task = asyncio.create_task(self._client.get_postfilter())
|
||||
|
||||
self.fan = await fan_task
|
||||
self.pwm = await pwm_task
|
||||
if self._poll_for_report:
|
||||
self.report = await report_task
|
||||
self.pid = await pid_task
|
||||
self.thermistor = await thermistor_task
|
||||
self.postfilter = await postfilter_task
|
||||
(
|
||||
self.fan,
|
||||
self.pwm,
|
||||
self.report,
|
||||
self.pid,
|
||||
self.thermistor,
|
||||
self.postfilter,
|
||||
) = await asyncio.gather(
|
||||
self._client.get_fan(),
|
||||
self._client.get_pwm(),
|
||||
self._client.report(),
|
||||
self._client.get_pid(),
|
||||
self._client.get_steinhart_hart(),
|
||||
self._client.get_postfilter(),
|
||||
)
|
||||
else:
|
||||
self.fan, self.pwm, self.pid, self.thermistor, self.postfilter = (
|
||||
await asyncio.gather(
|
||||
self._client.get_fan(),
|
||||
self._client.get_pwm(),
|
||||
self._client.get_pid(),
|
||||
self._client.get_steinhart_hart(),
|
||||
self._client.get_postfilter(),
|
||||
)
|
||||
)
|
||||
|
||||
def connected(self):
|
||||
return self._client.connected()
|
||||
|
Loading…
Reference in New Issue
Block a user