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
07035b7e
Commit
07035b7e
authored
Jul 07, 2023
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Down to one failing test.
parent
bd96d8e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
191 deletions
+132
-191
src/gevent/_socket3.py
src/gevent/_socket3.py
+15
-25
src/gevent/_socketcommon.py
src/gevent/_socketcommon.py
+24
-49
src/gevent/events.py
src/gevent/events.py
+1
-1
src/gevent/testing/patched_tests_setup.py
src/gevent/testing/patched_tests_setup.py
+92
-116
No files found.
src/gevent/_socket3.py
View file @
07035b7e
...
...
@@ -110,31 +110,21 @@ class socket(_socketcommon.SocketMixin):
# don't subclass it. This lets code that needs the raw _sock (not tied to the hub)
# get it. This shows up in tests like test__example_udp_server.
if
sys
.
version_info
[:
2
]
<
(
3
,
7
):
def
__init__
(
self
,
family
=
AF_INET
,
type
=
SOCK_STREAM
,
proto
=
0
,
fileno
=
None
):
super
().
__init__
()
self
.
_closed
=
False
self
.
_sock
=
self
.
_gevent_sock_class
(
family
,
type
,
proto
,
fileno
)
self
.
timeout
=
None
self
.
__init_common
()
else
:
# In 3.7, socket changed to auto-detecting family, type, and proto
# when given a fileno.
def
__init__
(
self
,
family
=-
1
,
type
=-
1
,
proto
=-
1
,
fileno
=
None
):
super
().
__init__
()
self
.
_closed
=
False
if
fileno
is
None
:
if
family
==
-
1
:
family
=
AF_INET
if
type
==
-
1
:
type
=
SOCK_STREAM
if
proto
==
-
1
:
proto
=
0
self
.
_sock
=
self
.
_gevent_sock_class
(
family
,
type
,
proto
,
fileno
)
self
.
timeout
=
None
self
.
__init_common
()
def
__init_common
(
self
):
# In 3.7, socket changed to auto-detecting family, type, and proto
# when given a fileno.
def
__init__
(
self
,
family
=-
1
,
type
=-
1
,
proto
=-
1
,
fileno
=
None
):
super
().
__init__
()
self
.
_closed
=
False
if
fileno
is
None
:
if
family
==
-
1
:
family
=
AddressFamily
.
AF_INET
if
type
==
-
1
:
type
=
SOCK_STREAM
if
proto
==
-
1
:
proto
=
0
self
.
_sock
=
self
.
_gevent_sock_class
(
family
,
type
,
proto
,
fileno
)
self
.
timeout
=
None
self
.
_io_refs
=
0
_socket
.
socket
.
setblocking
(
self
.
_sock
,
False
)
fileno
=
_socket
.
socket
.
fileno
(
self
.
_sock
)
...
...
src/gevent/_socketcommon.py
View file @
07035b7e
...
...
@@ -51,9 +51,6 @@ __imports__ = [
'setdefaulttimeout'
,
# Windows:
'errorTab'
,
]
__py3_imports__
=
[
# Python 3
'AddressFamily'
,
'SocketKind'
,
...
...
@@ -64,15 +61,15 @@ __py3_imports__ = [
'if_nameindex'
,
'if_nametoindex'
,
'sethostname'
,
'create_server'
,
'has_dualstack_ipv6'
,
]
__imports__
.
extend
(
__py3_imports__
)
import
time
from
gevent._hub_local
import
get_hub_noargs
as
get_hub
from
gevent._compat
import
string_types
,
integer_types
,
PY3
from
gevent._compat
import
PY38
from
gevent._compat
import
string_types
,
integer_types
from
gevent._compat
import
PY39
from
gevent._compat
import
WIN
as
is_windows
from
gevent._compat
import
OSX
as
is_macos
...
...
@@ -83,11 +80,6 @@ from gevent._hub_primitives import wait_on_socket as _wait_on_socket
from
gevent.timeout
import
Timeout
if
PY38
:
__imports__
.
extend
([
'create_server'
,
'has_dualstack_ipv6'
,
])
if
PY39
:
__imports__
.
extend
([
...
...
@@ -210,8 +202,7 @@ def gethostbyname_ex(hostname):
"""
return
get_hub
().
resolver
.
gethostbyname_ex
(
hostname
)
def
getaddrinfo
(
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
def
getaddrinfo
(
host
,
port
,
family
=
0
,
type
=
0
,
proto
=
0
,
flags
=
0
):
"""
Resolve host and port into list of address info entries.
...
...
@@ -228,40 +219,24 @@ def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0):
.. seealso:: :doc:`/dns`
"""
return
get_hub
().
resolver
.
getaddrinfo
(
host
,
port
,
family
,
socktype
,
proto
,
flags
)
if
PY3
:
# The name of the socktype param changed to type in Python 3.
# See https://github.com/gevent/gevent/issues/960
# Using inspect here to directly detect the condition is painful because we have to
# wrap it with a try/except TypeError because not all Python 2
# versions can get the args of a builtin; we also have to use a with to suppress
# the deprecation warning.
d
=
getaddrinfo
.
__doc__
def
getaddrinfo
(
host
,
port
,
family
=
0
,
type
=
0
,
proto
=
0
,
flags
=
0
):
# pylint:disable=function-redefined, undefined-variable
# Also, on Python 3, we need to translate into the special enums.
# Our lower-level resolvers, including the thread and blocking, which use _socket,
# function simply with integers.
addrlist
=
get_hub
().
resolver
.
getaddrinfo
(
host
,
port
,
family
,
type
,
proto
,
flags
)
result
=
[
(
_intenum_converter
(
af
,
AddressFamily
),
_intenum_converter
(
socktype
,
SocketKind
),
proto
,
canonname
,
sa
)
for
af
,
socktype
,
proto
,
canonname
,
sa
in
addrlist
]
return
result
getaddrinfo
.
__doc__
=
d
del
d
def
_intenum_converter
(
value
,
enum_klass
):
try
:
return
enum_klass
(
value
)
except
ValueError
:
# pragma: no cover
return
value
# Also, on Python 3, we need to translate into the special enums.
# Our lower-level resolvers, including the thread and blocking, which use _socket,
# function simply with integers.
addrlist
=
get_hub
().
resolver
.
getaddrinfo
(
host
,
port
,
family
,
type
,
proto
,
flags
)
result
=
[
(
_intenum_converter
(
af
,
AddressFamily
),
_intenum_converter
(
socktype
,
SocketKind
),
proto
,
canonname
,
sa
)
for
af
,
socktype
,
proto
,
canonname
,
sa
in
addrlist
]
return
result
def
_intenum_converter
(
value
,
enum_klass
):
try
:
return
enum_klass
(
value
)
except
ValueError
:
# pragma: no cover
return
value
def
gethostbyaddr
(
ip_address
):
...
...
@@ -546,8 +521,8 @@ class SocketMixin(object):
self
.
hub
.
cancel_wait
(
self
.
_write_event
,
cancel_wait_ex
)
self
.
_sock
.
shutdown
(
how
)
family
=
property
(
lambda
self
:
self
.
_sock
.
family
)
type
=
property
(
lambda
self
:
self
.
_sock
.
type
)
family
=
property
(
lambda
self
:
_intenum_converter
(
self
.
_sock
.
family
,
AddressFamily
)
)
type
=
property
(
lambda
self
:
_intenum_converter
(
self
.
_sock
.
type
,
SocketKind
)
)
proto
=
property
(
lambda
self
:
self
.
_sock
.
proto
)
def
fileno
(
self
):
...
...
src/gevent/events.py
View file @
07035b7e
...
...
@@ -123,7 +123,7 @@ def notify_and_call_entry_points(event):
# Prior to 3.9, there is no ``.module`` attribute, so if we
# needed that we'd have to look at the complete ``.value``
# attribute.
ep_dict
=
entry_points
()
ep_dict
=
metadata
.
entry_points
()
__traceback_info__
=
ep_dict
# On Python 3.8, we can get duplicate EntryPoint objects; it is unclear
# why. Drop them into a set to make sure we only get one.
...
...
src/gevent/testing/patched_tests_setup.py
View file @
07035b7e
...
...
@@ -115,17 +115,9 @@ def get_switch_expected(fullname):
disabled_tests = [
# "test an implementation detail of thread objects" --- our implementation differs
"test_threading.ThreadTests.test_tstate_lock",
# This likes to check the number of native thread IDs using the ``native_id`` attribute,
# and the ``get_native_id()`` function. Because we'
re
monkey
-
patched
,
# those don't change in other threads, so it won't work.
'test_threading.ThreadTests.test_various_ops'
,
# Added to address CPython issue 27718; it wants functions in the signal
# module to have __module__ equal to 'signal', but obviously when we
# monkey patch they don't.
# Want'
s
__module__
to
be
'signal'
,
which
of
course
it
isn
't once
# monkey-patched.
'
test_signal
.
GenericTests
.
test_functions_module_attr
',
# XXX: While we debug latest updates. This is leaking
'
test_threading
.
ThreadTests
.
test_no_refcycle_through_target
',
...
...
@@ -268,13 +260,6 @@ disabled_tests = [
]
if
sys
.
version_info
[:
3
]
<
(
2
,
7
,
18
):
# The final release was 2.7.18. It added some new tests for new
# fixes. At this writing, AppVeyor is still on 2.7.17.
disabled_tests
+=
[
'test_urllib2.MiscTests.test_url_host_with_control_char_rejected'
,
]
if
OSX
:
disabled_tests
+=
[
# These are timing dependent, and sometimes run into the OS X
...
...
@@ -548,15 +533,6 @@ class _PatchedTest(object):
return
test
if
sys
.
version_info
[:
3
]
<=
(
2
,
7
,
11
):
disabled_tests
+=
[
# These were added/fixed in 2.7.12+
'test_ssl.ThreadedTests.test__https_verify_certificates'
,
'test_ssl.ThreadedTests.test__https_verify_envvar'
,
]
if
OSX
:
disabled_tests
+=
[
'test_subprocess.POSIXProcessTestCase.test_run_abort'
,
...
...
@@ -644,101 +620,101 @@ if PYPY:
disabled_tests
+=
[
# Triggers the crash reporter
'test_threading.SubinterpThreadingTests.test_daemon_threads_fatal_error'
,
# Relies on an implementation detail, Thread._tstate_lock
'test_threading.ThreadTests.test_tstate_lock'
,
# Relies on an implementation detail (reprs); we have our own version
'test_threading.ThreadTests.test_various_ops'
,
'test_threading.ThreadTests.test_various_ops_large_stack'
,
'test_threading.ThreadTests.test_various_ops_small_stack'
,
# Relies on Event having a _cond and an _reset_internal_locks()
# XXX: These are commented out in the source code of test_threading because
# this doesn't work.
# 'lock_tests.EventTests.test_reset_internal_locks',
# Python bug 13502. We may or may not suffer from this as its
# basically a timing race condition.
# XXX Same as above
# 'lock_tests.EventTests.test_set_and_clear',
# These tests want to assert on the type of the class that implements
# `Popen.stdin`; we use a FileObject, but they expect different subclasses
# from the `io` module
'test_subprocess.ProcessTestCase.test_io_buffered_by_default'
,
'test_subprocess.ProcessTestCase.test_io_unbuffered_works'
,
# 3.3 exposed the `endtime` argument to wait accidentally.
# It is documented as deprecated and not to be used since 3.4
# This test in 3.6.3 wants to use it though, and we don't have it.
'test_subprocess.ProcessTestCase.test_wait_endtime'
,
# These all want to inspect the string value of an exception raised
# by the exec() call in the child. The _posixsubprocess module arranges
# for better exception handling and printing than we do.
'test_subprocess.POSIXProcessTestCase.test_exception_bad_args_0'
,
'test_subprocess.POSIXProcessTestCase.test_exception_bad_executable'
,
'test_subprocess.POSIXProcessTestCase.test_exception_cwd'
,
# Relies on a 'fork_exec' attribute that we don't provide
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_bad_data'
,
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_normal'
,
# Python 3 fixed a bug if the stdio file descriptors were closed;
# we still have that bug
'test_subprocess.POSIXProcessTestCase.test_small_errpipe_write_fd'
,
# Relies on implementation details (some of these tests were added in 3.4,
# but PyPy3 is also shipping them.)
'test_socket.GeneralModuleTests.test_SocketType_is_socketobject'
,
'test_socket.GeneralModuleTests.test_dealloc_warn'
,
'test_socket.GeneralModuleTests.test_repr'
,
'test_socket.GeneralModuleTests.test_str_for_enums'
,
'test_socket.GeneralModuleTests.testGetaddrinfo'
,
disabled_tests
+=
[
# Triggers the crash reporter
'test_threading.SubinterpThreadingTests.test_daemon_threads_fatal_error'
,
]
if
TRAVIS
:
disabled_tests
+=
[
# test_cwd_with_relative_executable tends to fail
# on Travis...it looks like the test processes are stepping
# on each other and messing up their temp directories. We tend to get things like
# saved_dir = os.getcwd()
# FileNotFoundError: [Errno 2] No such file or directory
'test_subprocess.ProcessTestCase.test_cwd_with_relative_arg'
,
'test_subprocess.ProcessTestCaseNoPoll.test_cwd_with_relative_arg'
,
'test_subprocess.ProcessTestCase.test_cwd_with_relative_executable'
,
# In 3.7 and 3.8 on Travis CI, this appears to take the full 3 seconds.
# Can't reproduce it locally. We have our own copy of this that takes
# timing on CI into account.
'test_subprocess.RunFuncTestCase.test_run_with_shell_timeout_and_capture_output'
,
]
# Relies on an implementation detail, Thread._tstate_lock
'test_threading.ThreadTests.test_tstate_lock'
,
# Relies on an implementation detail (reprs); we have our own version
'test_threading.ThreadTests.test_various_ops'
,
'test_threading.ThreadTests.test_various_ops_large_stack'
,
'test_threading.ThreadTests.test_various_ops_small_stack'
,
# Relies on Event having a _cond and an _reset_internal_locks()
# XXX: These are commented out in the source code of test_threading because
# this doesn't work.
# 'lock_tests.EventTests.test_reset_internal_locks',
# Python bug 13502. We may or may not suffer from this as its
# basically a timing race condition.
# XXX Same as above
# 'lock_tests.EventTests.test_set_and_clear',
# These tests want to assert on the type of the class that implements
# `Popen.stdin`; we use a FileObject, but they expect different subclasses
# from the `io` module
'test_subprocess.ProcessTestCase.test_io_buffered_by_default'
,
'test_subprocess.ProcessTestCase.test_io_unbuffered_works'
,
# 3.3 exposed the `endtime` argument to wait accidentally.
# It is documented as deprecated and not to be used since 3.4
# This test in 3.6.3 wants to use it though, and we don't have it.
'test_subprocess.ProcessTestCase.test_wait_endtime'
,
# These all want to inspect the string value of an exception raised
# by the exec() call in the child. The _posixsubprocess module arranges
# for better exception handling and printing than we do.
'test_subprocess.POSIXProcessTestCase.test_exception_bad_args_0'
,
'test_subprocess.POSIXProcessTestCase.test_exception_bad_executable'
,
'test_subprocess.POSIXProcessTestCase.test_exception_cwd'
,
# Relies on a 'fork_exec' attribute that we don't provide
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_bad_data'
,
'test_subprocess.POSIXProcessTestCase.test_exception_errpipe_normal'
,
# Python 3 fixed a bug if the stdio file descriptors were closed;
# we still have that bug
'test_subprocess.POSIXProcessTestCase.test_small_errpipe_write_fd'
,
# Relies on implementation details (some of these tests were added in 3.4,
# but PyPy3 is also shipping them.)
'test_socket.GeneralModuleTests.test_SocketType_is_socketobject'
,
'test_socket.GeneralModuleTests.test_dealloc_warn'
,
'test_socket.GeneralModuleTests.test_repr'
,
'test_socket.GeneralModuleTests.test_str_for_enums'
,
'test_socket.GeneralModuleTests.testGetaddrinfo'
,
]
if
TRAVIS
:
disabled_tests
+=
[
# XXX: BUG: We simply don't handle this correctly. On CPython,
# we wind up raising a BlockingIOError and then
# BrokenPipeError and then some random TypeErrors, all on the
# server. CPython 3.5 goes directly to socket.send() (via
# socket.makefile), whereas CPython 3.6 uses socket.sendall().
# On PyPy, the behaviour is much worse: we hang indefinitely, perhaps exposing a problem
# with our signal handling.
# In actuality, though, this test doesn't fully test the EINTR it expects
# to under gevent (because if its EWOULDBLOCK retry behaviour.)
# Instead, the failures were all due to `pthread_kill` trying to send a signal
# to a greenlet instead of a real thread. The solution is to deliver the signal
# to the real thread by letting it get the correct ID, and we previously
# used make_run_with_original to make it do that.
#
# But now that we have disabled our wrappers around Thread.join() in favor
# of the original implementation, that causes problems:
# background.join() thinks that it is the current thread, and won't let it
# be joined.
'test_wsgiref.IntegrationTests.test_interrupted_write'
,
# test_cwd_with_relative_executable tends to fail
# on Travis...it looks like the test processes are stepping
# on each other and messing up their temp directories. We tend to get things like
# saved_dir = os.getcwd()
# FileNotFoundError: [Errno 2] No such file or directory
'test_subprocess.ProcessTestCase.test_cwd_with_relative_arg'
,
'test_subprocess.ProcessTestCaseNoPoll.test_cwd_with_relative_arg'
,
'test_subprocess.ProcessTestCase.test_cwd_with_relative_executable'
,
# In 3.7 and 3.8 on Travis CI, this appears to take the full 3 seconds.
# Can't reproduce it locally. We have our own copy of this that takes
# timing on CI into account.
'test_subprocess.RunFuncTestCase.test_run_with_shell_timeout_and_capture_output'
,
]
disabled_tests
+=
[
# XXX: BUG: We simply don't handle this correctly. On CPython,
# we wind up raising a BlockingIOError and then
# BrokenPipeError and then some random TypeErrors, all on the
# server. CPython 3.5 goes directly to socket.send() (via
# socket.makefile), whereas CPython 3.6 uses socket.sendall().
# On PyPy, the behaviour is much worse: we hang indefinitely, perhaps exposing a problem
# with our signal handling.
# In actuality, though, this test doesn't fully test the EINTR it expects
# to under gevent (because if its EWOULDBLOCK retry behaviour.)
# Instead, the failures were all due to `pthread_kill` trying to send a signal
# to a greenlet instead of a real thread. The solution is to deliver the signal
# to the real thread by letting it get the correct ID, and we previously
# used make_run_with_original to make it do that.
#
# But now that we have disabled our wrappers around Thread.join() in favor
# of the original implementation, that causes problems:
# background.join() thinks that it is the current thread, and won't let it
# be joined.
'test_wsgiref.IntegrationTests.test_interrupted_write'
,
]
# PyPy3 3.5.5 v5.8-beta
if
PYPY3
:
...
...
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