asyncore question

Stéphane Ninin stefnin at alussinan.org
Mon Sep 29 16:28:47 CEST 2003


Also sprach Raymond Hettinger :

>>
>> I believe it's an oversight in asyncore.  
>> Either create_socket should take
>> a map parameter, or __init__ should store the initial map and
>> create_socket should use it.  One workaround is to create the socket
>> yourself and call set_socket(sock, some_map). 
> 
> Please submit a bug report.
> 
> 

  I think this patch should work,

*** 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 


should I add it first to the bug [758241],
or create a patch for it ?
In that case, how to connect the patch to the bug it is supposed to solve ?

I guess I am a bit out of topic here, in that case where should I ask 
such questions ?


Regards,

-- 
Stéphane Ninin







More information about the Python-list mailing list