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
93c6542e
Commit
93c6542e
authored
Oct 13, 2022
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run the leakchecks on Python 3.11
parent
beb98ce4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
8 deletions
+30
-8
.github/workflows/ci.yml
.github/workflows/ci.yml
+2
-3
src/gevent/resolver/__init__.py
src/gevent/resolver/__init__.py
+9
-0
src/gevent/resolver/ares.py
src/gevent/resolver/ares.py
+14
-1
src/gevent/resolver/cares.pyx
src/gevent/resolver/cares.pyx
+4
-4
src/gevent/tests/test__ares_timeout.py
src/gevent/tests/test__ares_timeout.py
+1
-0
No files found.
.github/workflows/ci.yml
View file @
93c6542e
...
...
@@ -350,11 +350,10 @@ jobs:
run
:
|
python -mgevent.tests --second-chance $G_USE_COV --ignore tests_that_dont_use_resolver.txt
-
name
:
"
Tests:
leakchecks"
# Run the leaktests; this seems to be extremely slow on Python 3.7
# XXX: Figure out why. Can we reproduce locally?
# Run the leaktests;
# This is incredibly important and we MUST have an environment that successfully passes
# these tests.
if
:
matrix.python-version == 2.7
&& startsWith(runner.os, 'Linux')
if
:
(matrix.python-version == 2.7 || startsWith(matrix.python-version, '3.11'))
&& startsWith(runner.os, 'Linux')
env
:
GEVENTTEST_LEAKCHECK
:
1
run
:
|
...
...
src/gevent/resolver/__init__.py
View file @
93c6542e
...
...
@@ -135,6 +135,15 @@ class AbstractResolver(object):
and
k
not
in
(
'SOCK_CLOEXEC'
,
'SOCK_MAX_SIZE'
)
}
def
close
(
self
):
"""
Release resources held by this object.
Subclasses that define resources should override.
.. versionadded:: NEXT
"""
@
staticmethod
def
fixup_gaierror
(
func
):
import
functools
...
...
src/gevent/resolver/ares.py
View file @
93c6542e
...
...
@@ -4,6 +4,7 @@ c-ares based hostname resolver.
"""
from
__future__
import
absolute_import
,
print_function
,
division
import
os
import
warnings
from
_socket
import
gaierror
from
_socket
import
herror
...
...
@@ -116,12 +117,17 @@ class Resolver(AbstractResolver):
Handling of localhost and broadcast names is now more consistent.
.. versionchanged:: NEXT
Now has a ``__del__`` method that warns if the object is destroyed
without being properly closed.
.. _c-ares: http://c-ares.haxx.se
"""
cares_class
=
channel
def
__init__
(
self
,
hub
=
None
,
use_environ
=
True
,
**
kwargs
):
AbstractResolver
.
__init__
(
self
)
if
hub
is
None
:
hub
=
get_hub
()
self
.
hub
=
hub
...
...
@@ -134,7 +140,7 @@ class Resolver(AbstractResolver):
self
.
cares
=
self
.
cares_class
(
hub
.
loop
,
**
kwargs
)
self
.
pid
=
os
.
getpid
()
self
.
params
=
kwargs
self
.
fork_watcher
=
hub
.
loop
.
fork
(
ref
=
False
)
self
.
fork_watcher
=
hub
.
loop
.
fork
(
ref
=
False
)
# We shouldn't keep the loop alive
self
.
fork_watcher
.
start
(
self
.
_on_fork
)
def
__repr__
(
self
):
...
...
@@ -149,11 +155,18 @@ class Resolver(AbstractResolver):
self
.
pid
=
pid
def
close
(
self
):
AbstractResolver
.
close
(
self
)
if
self
.
cares
is
not
None
:
self
.
hub
.
loop
.
run_callback
(
self
.
cares
.
destroy
)
self
.
cares
=
None
self
.
fork_watcher
.
stop
()
def
__del__
(
self
):
if
self
.
cares
is
not
None
:
warnings
.
warn
(
"cares Resolver destroyed while not closed"
,
ResourceWarning
)
self
.
close
()
def
_gethostbyname_ex
(
self
,
hostname_bytes
,
family
):
while
True
:
ares
=
self
.
cares
...
...
src/gevent/resolver/cares.pyx
View file @
93c6542e
...
...
@@ -412,6 +412,9 @@ cdef class channel:
return
'<%s at 0x%x _timer=%r _watchers[%s]>'
%
args
def
destroy
(
self
):
self
.
__destroy
()
cdef
__destroy
(
self
):
if
self
.
channel
:
# XXX ares_library_cleanup?
cares
.
ares_destroy
(
self
.
channel
)
...
...
@@ -421,10 +424,7 @@ cdef class channel:
self
.
loop
=
None
def
__dealloc__
(
self
):
if
self
.
channel
:
# XXX ares_library_cleanup?
cares
.
ares_destroy
(
self
.
channel
)
self
.
channel
=
NULL
self
.
__destroy
()
cpdef
set_servers
(
self
,
servers
=
None
):
if
not
self
.
channel
:
...
...
src/gevent/tests/test__ares_timeout.py
View file @
93c6542e
...
...
@@ -34,6 +34,7 @@ class TestTimeout(greentest.TestCase):
r
=
Resolver
(
servers
=
[
address
[
0
]],
timeout
=
0.001
,
tries
=
1
,
udp_port
=
address
[
-
1
])
self
.
_close_on_teardown
(
r
)
with
self
.
assertRaisesRegex
(
socket
.
herror
,
"ARES_ETIMEOUT"
):
r
.
gethostbyname
(
'www.google.com'
)
...
...
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