Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit d1f5bd9

Browse files
committed
fix sleep
1 parent a890ec8 commit d1f5bd9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lirc_watcher.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import socket
88
import fcntl
99
import errno
10-
import time
10+
from time import sleep
1111

1212
LONG_PRESS = os.getenv('LONG_PRESS', 12)
1313
READ_TIMEOUT = os.getenv('READ_TIMEOUT', 0.2)
@@ -91,9 +91,15 @@ def send_code(priority_data=None):
9191
err = e.args[0]
9292

9393
"""
94-
Check for "real" error, exclude empty data
94+
Check for "real" error
9595
"""
96-
if err != errno.EAGAIN or err != errno.EWOULDBLOCK:
96+
if err == errno.EAGAIN or err == errno.EWOULDBLOCK:
97+
sleep(0.01)
98+
continue
99+
else:
100+
print(e)
101+
mqtt.disconnect()
102+
mqtt.loop_stop()
97103
sys.exit(1)
98104
else:
99105
if new_data:
@@ -115,8 +121,6 @@ def send_code(priority_data=None):
115121
t = Timer(READ_TIMEOUT, send_code)
116122
t.start()
117123

118-
time.sleep(0.01)
119-
120124

121125
except KeyboardInterrupt:
122126
mqtt.disconnect()

0 commit comments

Comments
 (0)