Commit bf116779 authored by Jason Madden's avatar Jason Madden

Fix the backdoor server error on PyPy: there is a weakreference somewhere...

Fix the backdoor server error on PyPy: there is a weakreference somewhere keeping socket objects alive or a finalizer is involved so a judicious GC fixes the hangs...but ideally the dangling reference gets found and fixed.
parent 0da2329e
......@@ -7,8 +7,10 @@ from code import InteractiveConsole
from gevent import socket
from gevent.greenlet import Greenlet
from gevent.hub import PY3, getcurrent
from gevent.hub import PY3, PYPY, getcurrent
from gevent.server import StreamServer
if PYPY:
import gc
__all__ = ['BackdoorServer']
......@@ -77,6 +79,12 @@ class BackdoorServer(StreamServer):
finally:
conn.close()
f.close()
if PYPY:
# The underlying socket somewhere has a reference
# that's not getting closed until finalizers run.
# Without running them, test__backdoor.Test.test_sys_exit
# hangs forever
gc.collect()
class _fileobject(socket._fileobject):
......@@ -93,7 +101,6 @@ class _fileobject(socket._fileobject):
def readline(self, *a):
return socket._fileobject.readline(self, *a).replace("\r\n", "\n")
if __name__ == '__main__':
if not sys.argv[1:]:
print('USAGE: %s PORT' % sys.argv[0])
......
......@@ -78,7 +78,6 @@ if PYPY:
'test__pywsgi.py',
# No idea!
'test__backdoor.py',
'test__server.py',
'test_subprocess.py', # test_executable_without_cwd
'FLAKY test___example_servers.py',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment