Fix exception when attempting to select on a closed socket

This commit is contained in:
Charles Haley 2012-08-01 18:05:06 +02:00
parent 656a28986e
commit 11731fd030

View File

@ -447,13 +447,13 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
if self.is_connected:
self.noop_counter += 1
if only_presence and (self.noop_counter % 5) != 1:
try:
ans = select.select((self.device_socket,), (), (), 0)
if len(ans[0]) == 0:
return (True, self)
# The socket indicates that something is there. Given the
# protocol, this can only be a disconnect notification. Fall
# through and actually try to talk to the client.
try:
# This will usually toss an exception if the socket is gone.
if self._call_client('NOOP', dict())[0] is None:
self.is_connected = False