Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion devicehive/device_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def connect(self, transport_url, **options):
connect_timeout = options.pop('connect_timeout', 30)
max_num_connect = options.pop('max_num_connect', 10)
connect_interval = options.pop('connect_interval', 1)
transport_alive_timeout = options.pop('transport_alive_timeout', 0.01)
self._api_handler_options['auth'] = auth
self._init_transport()
connect_time = time.time()
Expand All @@ -47,7 +48,8 @@ def connect(self, transport_url, **options):
if self._transport.connected:
self._transport.disconnect()
self._transport.connect(transport_url, **options)
self._transport.join()
while self._transport.is_alive():
time.sleep(transport_alive_timeout)
exception_info = self._transport.exception_info
if exception_info and not isinstance(exception_info[1],
self._transport.error):
Expand Down
3 changes: 3 additions & 0 deletions devicehive/transports/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def disconnect(self):
def join(self, timeout=None):
self._connection_thread.join(timeout)

def is_alive(self):
return self._connection_thread.is_alive()

def send_request(self, request_id, action, request, **params):
raise NotImplementedError

Expand Down