]> git.michaelhowe.org Git - packages/p/paho-mqtt.git/commitdiff
Handle EAGAIN on Windows.
authorRoger Light <roger@atchoo.org>
Sat, 7 Dec 2013 23:21:53 +0000 (23:21 +0000)
committerRoger Light <roger@atchoo.org>
Mon, 3 Feb 2014 21:20:22 +0000 (21:20 +0000)
src/paho/mqtt/client.py

index 1a72c7967720a9c116f09e55c1275fc15a01137f..fae5f40edf61ddb8a6ec56c010171c667e43fabc 100755 (executable)
@@ -17,6 +17,7 @@ This is an MQTT v3.1 client module. MQTT is a lightweight pub/sub messaging
 protocol that is easy to implement and suitable for low powered devices.
 """
 import errno
+import platform
 import random
 import select
 import socket
@@ -39,6 +40,11 @@ try:
 except ImportError:
     HAVE_DNS = False
 
+if platform.system() == 'Windows':
+    EAGAIN = errno.WSAEWOULDBLOCK
+else:
+    EAGAIN = errno.EAGAIN
+
 if sys.version_info[0] < 3:
     PROTOCOL_NAME = "MQIsdp"
 else:
@@ -1244,7 +1250,7 @@ class Client:
                 (msg) = err
                 if self._ssl and (msg.errno == ssl.SSL_ERROR_WANT_READ or msg.errno == ssl.SSL_ERROR_WANT_WRITE):
                     return MQTT_ERR_AGAIN
-                if msg.errno == errno.EAGAIN:
+                if msg.errno == EAGAIN:
                     return MQTT_ERR_AGAIN
                 print(msg)
                 return 1
@@ -1268,7 +1274,7 @@ class Client:
                     (msg) = err
                     if self._ssl and (msg.errno == ssl.SSL_ERROR_WANT_READ or msg.errno == ssl.SSL_ERROR_WANT_WRITE):
                         return MQTT_ERR_AGAIN
-                    if msg.errno == errno.EAGAIN:
+                    if msg.errno == EAGAIN:
                         return MQTT_ERR_AGAIN
                     print(msg)
                     return 1
@@ -1300,7 +1306,7 @@ class Client:
                 (msg) = err
                 if self._ssl and (msg.errno == ssl.SSL_ERROR_WANT_READ or msg.errno == ssl.SSL_ERROR_WANT_WRITE):
                     return MQTT_ERR_AGAIN
-                if msg.errno == errno.EAGAIN:
+                if msg.errno == EAGAIN:
                     return MQTT_ERR_AGAIN
                 print(msg)
                 return 1
@@ -1339,7 +1345,7 @@ class Client:
                 (msg) = err
                 if self._ssl and (msg.errno == ssl.SSL_ERROR_WANT_READ or msg.errno == ssl.SSL_ERROR_WANT_WRITE):
                     return MQTT_ERR_AGAIN
-                if msg.errno == errno.EAGAIN:
+                if msg.errno == EAGAIN:
                     return MQTT_ERR_AGAIN
                 print(msg)
                 return 1