[Python-bugs-list] [ python-Bugs-758241 ] asyncore with non-default map problems

SourceForge.net noreply at sourceforge.net
Mon Sep 29 10:51:54 EDT 2003


Bugs item #758241, was opened at 2003-06-21 03:41
Message generated for change (Comment added) made by stephane_ninin
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=758241&group_id=5470

Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Bob Halley (rthalley)
Assigned to: A.M. Kuchling (akuchling)
Summary: asyncore with non-default map problems

Initial Comment:
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.



----------------------------------------------------------------------

Comment By: Stephane Ninin (stephane_ninin)
Date: 2003-09-29 16:51

Message:
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 





----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=758241&group_id=5470



More information about the Python-bugs-list mailing list