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
92fc2c5d
Commit
92fc2c5d
authored
Nov 08, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor test_ares_timeout to a proper test.
parent
5d106191
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
29 deletions
+56
-29
src/gevent/resolver_ares.py
src/gevent/resolver_ares.py
+7
-1
src/gevent/resolver_thread.py
src/gevent/resolver_thread.py
+8
-2
src/gevent/tests/test_ares_timeout.py
src/gevent/tests/test_ares_timeout.py
+40
-26
src/gevent/tests/tests_that_dont_do_leakchecks.txt
src/gevent/tests/tests_that_dont_do_leakchecks.txt
+1
-0
No files found.
src/gevent/resolver_ares.py
View file @
92fc2c5d
...
...
@@ -3,7 +3,13 @@
.. deprecated:: 1.3
Use :mod:`gevent.resolver.ares`
"""
import
warnings
warnings
.
warn
(
"gevent.resolver_ares is deprecated and will be removed in 1.5. "
"Use gevent.resolver.ares instead."
,
DeprecationWarning
)
del
warnings
from
gevent.resolver.ares
import
*
# pylint:disable=wildcard-import,unused-wildcard-import
import
gevent.resolver.ares
as
_ares
__all__
=
_ares
.
__all__
...
...
src/gevent/resolver_thread.py
View file @
92fc2c5d
"""Backwards compatibility alias for :mod:`gevent.resolver.thread`.
.. deprecated:: 1.3
Use :mod:`gevent.resolver.
cares
`
Use :mod:`gevent.resolver.
thread
`
"""
import
warnings
warnings
.
warn
(
"gevent.resolver_thread is deprecated and will be removed in 1.5. "
"Use gevent.resolver.thread instead."
,
DeprecationWarning
)
del
warnings
from
gevent.resolver.thread
import
*
# pylint:disable=wildcard-import,unused-wildcard-import
import
gevent.resolver.thread
as
_thread
__all__
=
_thread
.
__all__
...
...
src/gevent/tests/test_ares_timeout.py
View file @
92fc2c5d
from
__future__
import
print_function
import
sys
import
errno
import
unittest
import
gevent
try
:
from
gevent.resolver
_
ares
import
Resolver
from
gevent.resolver
.
ares
import
Resolver
except
ImportError
as
ex
:
print
(
ex
)
sys
.
exit
(
0
)
Resolver
=
None
from
gevent
import
socket
print
(
gevent
.
__file__
)
address
=
(
''
,
7153
)
listener
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
import
gevent.testing
as
greentest
try
:
listener
.
bind
(
address
)
except
socket
.
error
as
ex
:
if
ex
.
errno
in
(
errno
.
EPERM
,
errno
.
EADDRNOTAVAIL
)
or
'permission denied'
in
str
(
ex
).
lower
():
sys
.
stderr
.
write
(
'This test binds on port a port that was already in use or not allowed.
\
n
'
)
sys
.
exit
(
0
)
raise
@
unittest
.
skipIf
(
Resolver
is
None
,
"Needs ares resolver"
)
class
TestTimeout
(
greentest
.
TestCase
):
__timeout__
=
30
def
reader
():
while
True
:
print
(
listener
.
recvfrom
(
10000
))
address
=
(
''
,
7153
)
gevent
.
spawn
(
reader
)
def
test
(
self
):
listener
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
r
=
gevent
.
get_hub
().
resolver
=
Resolver
(
servers
=
[
'127.0.0.1'
],
timeout
=
0.001
,
tries
=
1
,
udp_port
=
address
[
-
1
])
try
:
result
=
r
.
gethostbyname
(
'www.google.com'
)
except
socket
.
gaierror
as
ex
:
if
'ARES_ETIMEOUT'
not
in
str
(
ex
):
raise
else
:
raise
AssertionError
(
'Expected timeout, got %r'
%
(
result
,
))
try
:
listener
.
bind
(
self
.
address
)
except
socket
.
error
as
ex
:
if
ex
.
errno
in
(
errno
.
EPERM
,
errno
.
EADDRNOTAVAIL
)
or
'permission denied'
in
str
(
ex
).
lower
():
raise
unittest
.
SkipTest
(
'This test binds on port a port that was already in use or not allowed.
\
n
'
)
raise
def
reader
():
while
True
:
listener
.
recvfrom
(
10000
)
gevent
.
spawn
(
reader
)
r
=
Resolver
(
servers
=
[
'127.0.0.1'
],
timeout
=
0.001
,
tries
=
1
,
udp_port
=
self
.
address
[
-
1
])
with
self
.
assertRaisesRegex
(
socket
.
gaierror
,
"ARES_ETIMEOUT"
):
r
.
gethostbyname
(
'www.google.com'
)
if
__name__
==
'__main__'
:
greentest
.
main
()
src/gevent/tests/tests_that_dont_do_leakchecks.txt
View file @
92fc2c5d
...
...
@@ -2,3 +2,4 @@ test___monkey_patching.py
test__monkey_ssl_warning.py
test___monitor.py
test__monkey_scope.py
test_ares_timeout.py
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