fix workers

This commit is contained in:
clowwindy 2015-08-01 19:09:29 +08:00
parent d319fab5ca
commit e8b2946999
3 changed files with 9 additions and 3 deletions

View file

@ -425,7 +425,9 @@ class DNSResolver(object):
def close(self):
if self._sock:
self._loop.remove(self._sock, self)
if self._loop:
self._loop.remove_periodic(self.handle_periodic)
self._loop.remove(self._sock, self)
self._sock.close()
self._sock = None

View file

@ -703,4 +703,7 @@ class TCPRelay(object):
def close(self, next_tick=False):
self._closed = True
if not next_tick:
if self._eventloop:
self._eventloop.remove_periodic(self.handle_periodic)
self._eventloop.remove(self._server_socket, self)
self._server_socket.close()

View file

@ -278,10 +278,11 @@ class UDPRelay(object):
self._server_socket.close()
for sock in self._sockets:
sock.close()
self._eventloop.remove_periodic(self.handle_periodic)
def close(self, next_tick=False):
self._closed = True
if not next_tick:
self._eventloop.remove(self._server_socket, self)
if self._eventloop:
self._eventloop.remove_periodic(self.handle_periodic)
self._eventloop.remove(self._server_socket, self)
self._server_socket.close()