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
9ae602e6
Commit
9ae602e6
authored
Nov 03, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core.pyx: simplify getaddrinfo_request
parent
ec2e21b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
27 deletions
+10
-27
gevent/core.pyx
gevent/core.pyx
+10
-27
No files found.
gevent/core.pyx
View file @
9ae602e6
...
...
@@ -270,7 +270,7 @@ cdef class evdns_base:
Py_INCREF
(
param
)
cdef
void
*
c_request
=
levent
.
evdns_getaddrinfo
(
self
.
_ptr
,
nodename
,
servname
,
&
hints
,
__getaddrinfo_handler
,
<
void
*>
param
)
if
c_request
:
request
=
getaddrinfo_request
(
self
.
base
,
<
size_t
>
c_request
)
request
=
getaddrinfo_request
(
<
size_t
>
c_request
)
param
.
append
(
request
)
return
request
...
...
@@ -290,11 +290,13 @@ cdef void __getaddrinfo_handler(int code, levent.evutil_addrinfo* res, void* c_p
else
:
callback
,
arg
,
request
=
param
if
request
is
not
None
:
if
request
.
base
is
None
:
# cancelled?
request
.
detach
()
return
request
.
detach
()
if
code
==
levent
.
EVUTIL_EAI_CANCEL
:
return
if
request
is
not
None
and
not
request
.
_ptr
:
return
request
.
detach
()
if
code
:
callback
(
None
,
gaierror
(
code
,
get_gaierror
(
code
)),
arg
)
...
...
@@ -323,11 +325,9 @@ cdef void __getaddrinfo_handler(int code, levent.evutil_addrinfo* res, void* c_p
cdef
class
getaddrinfo_request
:
cdef
public
event_base
base
cdef
void
*
_ptr
def
__init__
(
self
,
event_base
base
,
size_t
ptr
=
0
):
self
.
base
=
base
def
__init__
(
self
,
size_t
ptr
=
0
):
self
.
_ptr
=
<
void
*>
ptr
property
ptr
:
...
...
@@ -339,31 +339,14 @@ cdef class getaddrinfo_request:
return
'<%s ptr=%x>'
%
(
self
.
__class__
.
__name__
,
self
.
ptr
)
def
detach
(
self
):
self
.
base
=
None
self
.
_ptr
=
NULL
def
_
cancel
(
self
):
def
cancel
(
self
):
cdef
void
*
ptr
=
self
.
_ptr
if
ptr
:
self
.
_ptr
=
NULL
# self.base is already None
levent
.
evdns_getaddrinfo_cancel
(
ptr
)
def
cancel
(
self
):
if
self
.
_ptr
and
self
.
base
is
not
None
:
# cannot just all evdns_getaddrinfo_cancel here, because it might calls the user's callback immediateally
# and we only want to call the callbacks in the hub
self
.
base
.
active_event
(
self
.
_cancel
)
self
.
base
=
None
# setting base to None to let __getaddrinfo_handler figure out that the
# request was cancelled, even if _cancel was not executed yet;
# also to make sure that following up calls to cancel has not effect
@
property
def
pending
(
self
):
if
self
.
_ptr
:
return
self
.
base
is
not
None
cdef
void
__event_handler
(
int
fd
,
short
evtype
,
void
*
arg
)
with
gil
:
cdef
event
self
=
<
event
>
arg
...
...
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