Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
659c1f65
Commit
659c1f65
authored
9 years ago
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test__refcount under Py3
parent
f848ffac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
gevent/_socket3.py
gevent/_socket3.py
+1
-0
greentest/test__refcount.py
greentest/test__refcount.py
+19
-9
known_failures.py
known_failures.py
+0
-1
No files found.
gevent/_socket3.py
View file @
659c1f65
...
...
@@ -198,6 +198,7 @@ class socket(object):
self
.
hub
.
cancel_wait
(
self
.
_read_event
,
cancel_wait_ex
)
self
.
hub
.
cancel_wait
(
self
.
_write_event
,
cancel_wait_ex
)
_ss
.
close
(
self
.
_sock
)
self
.
_sock
=
None
def
close
(
self
):
# This function should not reference any globals. See Python issue #808164.
...
...
This diff is collapsed.
Click to expand it.
greentest/test__refcount.py
View file @
659c1f65
...
...
@@ -24,10 +24,18 @@ are not leaked by the hub.
"""
from
__future__
import
print_function
from
_socket
import
socket
class
Socket
(
socket
):
"Something we can have a weakref to"
import
sys
if
sys
.
version_info
[
0
]
>=
3
:
# Python3 enforces that __weakref__ appears only once,
# and not when a slotted class inherits from an unslotted class.
# We mess around with the class MRO below and violate that rule
# (because socket.socket defines __slots__ with __weakref__),
# so import socket.socket before that can happen.
__import__
(
'socket'
)
Socket
=
socket
else
:
class
Socket
(
socket
):
"Something we can have a weakref to"
import
_socket
_socket
.
socket
=
Socket
...
...
@@ -69,9 +77,9 @@ def handle_request(s, raise_on_timeout):
return
#print('handle_request - accepted')
res
=
conn
.
recv
(
100
)
assert
res
==
'hello'
,
repr
(
res
)
assert
res
==
b
'hello'
,
repr
(
res
)
#print('handle_request - recvd %r' % res)
res
=
conn
.
send
(
'bye'
)
res
=
conn
.
send
(
b
'bye'
)
#print('handle_request - sent %r' % res)
#print('handle_request - conn refcount: %s' % sys.getrefcount(conn))
#conn.close()
...
...
@@ -82,10 +90,10 @@ def make_request(port):
s
=
socket
.
socket
()
s
.
connect
((
'127.0.0.1'
,
port
))
#print('make_request - connected')
res
=
s
.
send
(
'hello'
)
res
=
s
.
send
(
b
'hello'
)
#print('make_request - sent %s' % res)
res
=
s
.
recv
(
100
)
assert
res
==
'bye'
,
repr
(
res
)
assert
res
==
b
'bye'
,
repr
(
res
)
#print('make_request - recvd %r' % res)
#s.close()
...
...
@@ -99,7 +107,9 @@ def run_interaction(run_client):
sleep
(
0.1
+
SOCKET_TIMEOUT
)
#print(sys.getrefcount(s._sock))
#s.close()
return
weakref
.
ref
(
s
.
_sock
)
w
=
weakref
.
ref
(
s
.
_sock
)
s
.
close
()
return
w
def
run_and_check
(
run_client
):
...
...
This diff is collapsed.
Click to expand it.
known_failures.py
View file @
659c1f65
...
...
@@ -81,7 +81,6 @@ if PYPY:
if
PY3
:
# No idea / TODO
FAILING_TESTS
+=
'''
test__refcount.py
test__all__.py
test__pywsgi.py
test__makefile_ref.py
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment