Make command timeout for workers configurable (#62)
This commit is contained in:
@@ -6,6 +6,9 @@ from workers.base import BaseWorker
|
||||
REQUIREMENTS = ['git+https://github.com/zewelor/linak_bt_desk.git@aa9412f98b3044be34c70e89d02721e6813ea731#egg=linak_bt_desk']
|
||||
|
||||
class LinakdeskWorker(BaseWorker):
|
||||
|
||||
SCAN_TIMEOUT = 20
|
||||
|
||||
def _setup(self):
|
||||
from linak_dpg_bt import LinakDesk
|
||||
|
||||
@@ -15,7 +18,7 @@ class LinakdeskWorker(BaseWorker):
|
||||
return [MqttMessage(topic=self.format_topic('height/cm'), payload=self._get_height())]
|
||||
|
||||
def _get_height(self):
|
||||
with timeout(20, exception=TimeoutError):
|
||||
with timeout(SCAN_TIMEOUT, exception=TimeoutError('Retrieving the height from {} device {} timed out after {} seconds'.format(repr(self), self.mac, SCAN_TIMEOUT))):
|
||||
self.desk.read_dpg_data()
|
||||
return self.desk.current_height_with_offset.cm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user