Merge pull request #20457 from cachedout/more_socket_iter

Iterate over the socket copy
This commit is contained in:
Thomas S Hatch 2015-02-09 10:12:35 -07:00
commit 97f91e5817

View File

@ -9,7 +9,6 @@ in here
from __future__ import absolute_import
import logging
import gc
import copy
# Import salt libs
import salt.log
@ -197,9 +196,9 @@ class SREQ(object):
delete socket if you have it
'''
if hasattr(self, '_socket'):
sockets = copy.copy(self.poller.sockets)
if isinstance(self.poller.sockets, dict):
for socket in six.iterkeys(self.poller.sockets):
sockets = list(self.poller.sockets.keys())
for socket in sockets:
log.trace('Unregistering socket: {0}'.format(socket))
self.poller.unregister(socket)
else:
@ -242,15 +241,15 @@ class SREQ(object):
return self.send(enc, load, tries, timeout)
def destroy(self):
sockets = copy.copy(self.poller.sockets)
if isinstance(sockets, dict):
for socket in six.iterkeys(self.poller.sockets):
if isinstance(self.poller.sockets, dict):
sockets = list(self.poller.sockets.keys())
for socket in sockets:
if socket.closed is False:
socket.setsockopt(zmq.LINGER, 1)
socket.close()
self.poller.unregister(socket)
else:
for socket in sockets:
for socket in self.poller.sockets:
if socket[0].closed is False:
socket[0].setsockopt(zmq.LINGER, 1)
socket[0].close()