Skip to content

Commit 15ed248

Browse files
committed
add case where connection fails
1 parent 9f07bb8 commit 15ed248

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pyghthouse/ph.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,14 @@ def start(self):
212212
self.connect()
213213
self.stop()
214214
self.msg_handler.reset()
215-
while not self.connector.connection_state==ConnectionState.CONNECTED:
215+
while True:
216+
state=self.connector.connection_state
217+
if state==ConnectionState.CONNECTED:
218+
# Connected
219+
break
220+
elif state==ConnectionState.FAILED:
221+
# Connection failed
222+
raise ConnectionError("Failed to connect")
216223
sleep(100)
217224
self.ph_thread = self.PHThread(self)
218225
self.ph_thread.start()

0 commit comments

Comments
 (0)