Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion winloop/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# supported platforms, publish the packages on PyPI, merge the PR
# to the target branch, create a Git tag pointing to the commit.

__version__ = '0.6.4'
__version__ = '0.7.0'
4 changes: 2 additions & 2 deletions winloop/loop.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ cdef class Loop:
cdef inline _check_closed(self)
cdef inline _check_thread(self)

cdef _getaddrinfo(self, object host, object port,
cdef Future _getaddrinfo(self, object host, object port,
int family, int type,
int proto, int flags,
int unpack)

cdef _getnameinfo(self, system.sockaddr *addr, int flags)
cdef Future _getnameinfo(self, system.sockaddr *addr, int flags)

cdef _track_transport(self, UVBaseTransport transport)
cdef _fileobj_to_fd(self, fileobj)
Expand Down
21 changes: 17 additions & 4 deletions winloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ cdef class Loop:

return result

# TODO: signature of bint or int return except -1 would be better here.
cdef _has_writer(self, fileobj):
cdef:
UVPoll poll
Expand All @@ -891,11 +892,13 @@ cdef class Loop:

return poll.is_writing()

cdef _getaddrinfo(self, object host, object port,
cdef Future _getaddrinfo(self, object host, object port,
int family, int type,
int proto, int flags,
int unpack):

cdef Future fut

if isinstance(port, str):
port = port.encode()
elif isinstance(port, int):
Expand All @@ -909,8 +912,14 @@ cdef class Loop:
if not isinstance(host, bytes):
raise TypeError('host must be a str or bytes')

fut = self._new_future()
# TODO: Use _new_future to return compiled Future objects
# in a later update (0.8.0)
fut = Future(loop=self)

# TODO: Sometime before or after 0.8.0,
# Let's Convert this callback to a ctypedef callback
# for added performance.
# example: ctypedef int (*addrinfo_callback)(Future fut, object result) except -1
def callback(result):
if AddrInfo.isinstance(result):
try:
Expand All @@ -933,10 +942,14 @@ cdef class Loop:
AddrInfoRequest(self, host, port, family, type, proto, flags, callback)
return fut

cdef _getnameinfo(self, system.sockaddr *addr, int flags):
cdef Future _getnameinfo(self, system.sockaddr *addr, int flags):
cdef NameInfoRequest nr
fut = self._new_future()
cdef Future fut
fut = Future(loop=self)

# Ditto of 0.8.0's TODO list:
# Something like ctypedef int (*nameinfo_callback)(Future, object) except -1
# would be sufficient.
def callback(result):
if isinstance(result, tuple):
fut.set_result(result)
Expand Down
Loading