Skip to content

Commit

Permalink
greenio: When we mark a socket as closed we still need to be able to …
Browse files Browse the repository at this point in the history
…close it

eventlet#122

After a long running job that highlighted a previous known issue with
Second Simultaneous Read issue I used http://mg.pov.lt/objgraph/ to print
out all the types and counts still referenced by the GC.

Before this patch I was seeing GreenSocket and _socketobject types been
referenced. Depending on how long I ran the test job for I saw more references
to these objects. After this patch I see no reference no matter how long I
run my test for.
  • Loading branch information
Michael Kerrin authored and temoto committed Aug 27, 2014
1 parent 203e629 commit d4d09ac
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions eventlet/greenio.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,13 @@ def accept(self):
self._trampoline(fd, read=True, timeout=self.gettimeout(),
timeout_exc=socket.timeout("timed out"))

def _defanged_close(self):
# Already closed the once
pass


def _mark_as_closed(self):
""" Mark this socket as being closed """
self.close = self._defanged_close
self._closed = True

def close(self):
notify_close(self.fd)
self._mark_as_closed() # Don't do this twice.
self._mark_as_closed()
return self.fd.close()

def __del__(self):
Expand Down Expand Up @@ -433,12 +427,7 @@ def _trampoline(self, fd, read=False, write=False, timeout=None, timeout_exc=Non
self._mark_as_closed()
raise

def _defanged_close(self):
# Don't let anything close the wrong filehandle.
pass

def _mark_as_closed(self):
self.close = self._close = self._defanged_close
self._closed = True

@property
Expand Down Expand Up @@ -570,14 +559,7 @@ def __repr__(self):
self.mode,
(id(self) < 0) and (sys.maxint + id(self)) or id(self))

def _defanged_close(self):
pass

def _mark_as_closed(self):
self.close = self._defanged_close

def close(self):
self._mark_as_closed()
super(GreenPipe, self).close()
for method in [
'fileno', 'flush', 'isatty', 'next', 'read', 'readinto',
Expand Down

0 comments on commit d4d09ac

Please sign in to comment.