mirror of https://github.com/python/cpython.git
[Bug #758241] When you use asyncore with a non-default map, methods
of the dispatcher object break. e.g. if you close() the object, it tries to remove itself from the default map, not from the map the dispatcher was created with. The patch, from Stephane Ninin, records the map as an attribute of the dispatcher instance. 2.3 bugfix candidate.
This commit is contained in:
parent
d22bb6584d
commit
f9ca409292
|
@ -201,6 +201,11 @@ class dispatcher:
|
||||||
addr = None
|
addr = None
|
||||||
|
|
||||||
def __init__(self, sock=None, map=None):
|
def __init__(self, sock=None, map=None):
|
||||||
|
if map is None:
|
||||||
|
self._map = socket_map
|
||||||
|
else:
|
||||||
|
self._map = map
|
||||||
|
|
||||||
if sock:
|
if sock:
|
||||||
self.set_socket(sock, map)
|
self.set_socket(sock, map)
|
||||||
# I think it should inherit this anyway
|
# I think it should inherit this anyway
|
||||||
|
@ -232,13 +237,13 @@ def __repr__(self):
|
||||||
def add_channel(self, map=None):
|
def add_channel(self, map=None):
|
||||||
#self.log_info('adding channel %s' % self)
|
#self.log_info('adding channel %s' % self)
|
||||||
if map is None:
|
if map is None:
|
||||||
map = socket_map
|
map = self._map
|
||||||
map[self._fileno] = self
|
map[self._fileno] = self
|
||||||
|
|
||||||
def del_channel(self, map=None):
|
def del_channel(self, map=None):
|
||||||
fd = self._fileno
|
fd = self._fileno
|
||||||
if map is None:
|
if map is None:
|
||||||
map = socket_map
|
map = self._map
|
||||||
if map.has_key(fd):
|
if map.has_key(fd):
|
||||||
#self.log_info('closing channel %d:%s' % (fd, self))
|
#self.log_info('closing channel %d:%s' % (fd, self))
|
||||||
del map[fd]
|
del map[fd]
|
||||||
|
|
Loading…
Reference in New Issue