[Python-bugs-list] [ python-Bugs-808164 ] socket.close() doesn't play well with __del__

SourceForge.net noreply at sourceforge.net
Wed Sep 17 17:16:56 EDT 2003


Bugs item #808164, was opened at 2003-09-17 17:16
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=808164&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Perry Greenfield (perrygreenfield)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket.close() doesn't play well with __del__

Initial Comment:
It appears that 2.3 changed how socket.close() works. 

We now find errors when terminating Python when we 

reference socket.close() in a __del__ method. We have 

worked around it by removing calls to socket.close() but 

note the following differences between the same section 

of code between 2.2 and 2.3 which suggest that the 2.3 

behavior is not ideal and should be fixed.



In Python 2.3:



    def close(self):

        self._sock = _closedsocket()

        self.send = self.recv = self.sendto = self.recvfrom \

                        = self._sock._dummy



In Python 2.2:



    def close(self):

        # Avoid referencing globals here

        self._sock = self.__class__._closedsocket()



Note the reference to avoiding globals which is 

presumably the source of the problem with 2.3. Perhaps 

I'm naive but I would guess that calling a close method 

should be considered a safe operation for use in a 

__del__ method.

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

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



More information about the Python-bugs-list mailing list