This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncore with non-default map problems
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, rthalley, stephane_ninin
Priority: normal Keywords:

Created on 2003-06-21 01:41 by rthalley, last changed 2022-04-10 16:09 by admin. This issue is now closed.

Messages (3)
msg16564 - (view) Author: Bob Halley (rthalley) Date: 2003-06-21 01:41
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.

There should be a map instance variable that contains
the map the object was created with, and it should be
used whenever the map needs to be referenced, e.g. in
add_channel/del_channel.

This would make close work correctly again.
msg16565 - (view) Author: Stephane Ninin (stephane_ninin) Date: 2003-09-29 14:51
Logged In: YES 
user_id=874382


I think this should solve the problem with non-default maps 
in asyncore.dispatcher. Hope this helps.

*** asyncore.py Mon Sep 29 16:20:13 2003
--- asyncore-new.py     Mon Sep 29 16:20:26 2003
***************
*** 201,206 ****
--- 201,211 ----
      addr = None

      def __init__(self, sock=None, map=None):
+         if (map is None):
+             self.map = socket_map
+         else:
+             self.map=map
+
          if sock:
              self.set_socket(sock, map)
              # I think it should inherit this anyway
***************
*** 248,254 ****
          self.socket = socket.socket(family, type)
          self.socket.setblocking(0)
          self._fileno = self.socket.fileno()
!         self.add_channel()

      def set_socket(self, sock, map=None):
          self.socket = sock
--- 253,259 ----
          self.socket = socket.socket(family, type)
          self.socket.setblocking(0)
          self._fileno = self.socket.fileno()
!         self.add_channel(self.map)

      def set_socket(self, sock, map=None):
          self.socket = sock
***************
*** 353,359 ****
                  raise socket.error, why

      def close(self):
!         self.del_channel()
          self.socket.close()

      # cheap inheritance, used to pass all other attribute
--- 358,364 ----
                  raise socket.error, why

      def close(self):
!         self.del_channel(self.map)
          self.socket.close()

      # cheap inheritance, used to pass all other attribute 

msg16566 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-10-22 13:49
Logged In: YES 
user_id=11375

Applied to the CVS trunk as rev 1.42 of asyncore.py.  Thanks to both of you for 
the patch, and for reporting the bug.
History
Date User Action Args
2022-04-10 16:09:22adminsetgithub: 38696
2003-06-21 01:41:00rthalleycreate