Skip to content

Commit c9d6b8d

Browse files
brentrubrentru
authored andcommitted
add non-blocking check for message
1 parent d2662ae commit c9d6b8d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adafruit_minimqtt.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,19 @@ def unsubscribe(self, topic):
533533
self._subscribed_topics.remove(t)
534534
return
535535

536+
def check_for_msg(self):
537+
"""Checks if a pending message from the server is avaliable.
538+
If not, returns None.
539+
"""
540+
self._sock.settimeout(0.1)
541+
self.wait_for_msg()
542+
536543
def wait_for_msg(self):
537544
"""Reads and processes network events.
538545
Returns response code if successful.
539546
"""
540-
self._sock.settimeout(30.0)
541547
res = self._sock.read(1)
548+
self._sock.settimeout(0.0)
542549
if res in [None, b""]:
543550
return None
544551
if res == MQTT_PINGRESP:

0 commit comments

Comments
 (0)