Browse Source

fix asyncmgr.py

dev
breakwa11 9 years ago
parent
commit
6e5744829c
  1. 13
      asyncmgr.py

13
asyncmgr.py

@ -55,8 +55,7 @@ class ServerMgr(object):
socket.SOL_UDP)
self._sock.bind((Config.MANAGE_BIND_IP, Config.MANAGE_PORT))
self._sock.setblocking(False)
loop.add(self._sock, eventloop.POLL_IN)
loop.add_handler(self.handle_events)
loop.add(self._sock, eventloop.POLL_IN, self)
def _handle_data(self, sock):
data, addr = sock.recvfrom(128)
@ -70,10 +69,9 @@ class ServerMgr(object):
elif args[3] == '1':
server_pool.ServerPool.get_instance().new_server(args[1], args[2])
def handle_events(self, events):
for sock, fd, event in events:
def handle_events(self, sock, event):
if sock != self._sock:
continue
return
if event & eventloop.POLL_ERR:
logging.error('mgr socket err')
self._loop.remove(self._sock)
@ -82,13 +80,14 @@ class ServerMgr(object):
self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,
socket.SOL_UDP)
self._sock.setblocking(False)
self._loop.add(self._sock, eventloop.POLL_IN)
self._loop.add(self._sock, eventloop.POLL_IN, self)
else:
self._handle_data(sock)
break
def close(self):
if self._sock:
if self._loop:
self._loop.remove(self._sock)
self._sock.close()
self._sock = None

Loading…
Cancel
Save