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
6babe9ad
Commit
6babe9ad
authored
Apr 23, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolver_ares: in case of fork, retry the request
parent
15702b2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
6 deletions
+40
-6
gevent/resolver_ares.py
gevent/resolver_ares.py
+40
-6
No files found.
gevent/resolver_ares.py
View file @
6babe9ad
...
...
@@ -39,9 +39,16 @@ class Resolver(object):
return
self
.
gethostbyname_ex
(
hostname
,
family
)[
-
1
][
0
]
def
gethostbyname_ex
(
self
,
hostname
,
family
=
AF_INET
):
waiter
=
Waiter
(
self
.
hub
)
self
.
ares
.
gethostbyname
(
waiter
,
hostname
,
family
)
return
waiter
.
get
()
while
True
:
ares
=
self
.
ares
try
:
waiter
=
Waiter
(
self
.
hub
)
ares
.
gethostbyname
(
waiter
,
hostname
,
family
)
return
waiter
.
get
()
except
gaierror
:
if
ares
is
self
.
ares
:
raise
# "self.ares is not ares" means channel was destroyed (because we were forked)
def
_lookup_port
(
self
,
port
,
socktype
):
if
isinstance
(
port
,
basestring
):
...
...
@@ -68,7 +75,7 @@ class Resolver(object):
port
=
0
return
port
,
socktype
def
getaddrinfo
(
self
,
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
def
_
getaddrinfo
(
self
,
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
if
isinstance
(
host
,
unicode
):
host
=
host
.
encode
(
'idna'
)
elif
not
isinstance
(
host
,
str
)
or
(
flags
&
AI_NUMERICHOST
):
...
...
@@ -126,7 +133,16 @@ class Resolver(object):
return
result
def
gethostbyaddr
(
self
,
ip_address
):
def
getaddrinfo
(
self
,
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
while
True
:
ares
=
self
.
ares
try
:
return
self
.
_getaddrinfo
(
host
,
port
,
family
,
socktype
,
proto
,
flags
)
except
gaierror
:
if
ares
is
self
.
ares
:
raise
def
_gethostbyaddr
(
self
,
ip_address
):
waiter
=
Waiter
(
self
.
hub
)
self
.
ares
.
gethostbyaddr
(
waiter
,
ip_address
)
try
:
...
...
@@ -142,7 +158,16 @@ class Resolver(object):
self
.
ares
.
gethostbyaddr
(
waiter
,
_ip_address
)
return
waiter
.
get
()
def
getnameinfo
(
self
,
sockaddr
,
flags
):
def
gethostbyaddr
(
self
,
ip_address
):
while
True
:
ares
=
self
.
ares
try
:
return
self
.
_gethostbyaddr
(
ip_address
)
except
gaierror
:
if
ares
is
self
.
ares
:
raise
def
_getnameinfo
(
self
,
sockaddr
,
flags
):
waiter
=
Waiter
(
self
.
hub
)
self
.
ares
.
getnameinfo
(
waiter
,
sockaddr
,
flags
)
try
:
...
...
@@ -161,6 +186,15 @@ class Resolver(object):
return
(
result
[
0
],
str
(
sockaddr
[
1
]))
+
result
[
2
:]
return
result
def
getnameinfo
(
self
,
sockaddr
,
flags
):
while
True
:
ares
=
self
.
ares
try
:
return
self
.
_getnameinfo
(
sockaddr
,
flags
)
except
gaierror
:
if
ares
is
self
.
ares
:
raise
class
Values
(
object
):
# helper to collect multiple values; ignore errors unless nothing has succeeded
...
...
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