mirror of https://github.com/MagicStack/uvloop.git
Make Future/Task compatible with asyncio in Python 3.6
This commit is contained in:
parent
db70c2be64
commit
d260c31206
|
@ -5,6 +5,22 @@ DEF _FUT_CANCELLED = 2
|
|||
DEF _FUT_FINISHED = 3
|
||||
|
||||
|
||||
cdef inline _future_get_blocking(fut):
|
||||
try:
|
||||
return fut._asyncio_future_blocking
|
||||
except AttributeError:
|
||||
return fut._blocking
|
||||
|
||||
|
||||
cdef inline _future_set_blocking(fut, val):
|
||||
try:
|
||||
fut._asyncio_future_blocking
|
||||
except AttributeError:
|
||||
fut._blocking = val
|
||||
else:
|
||||
fut._asyncio_future_blocking = val
|
||||
|
||||
|
||||
cdef class BaseFuture:
|
||||
cdef:
|
||||
int _state
|
||||
|
@ -36,6 +52,13 @@ cdef class BaseFuture:
|
|||
else:
|
||||
self._source_traceback = None
|
||||
|
||||
property _asyncio_future_blocking:
|
||||
def __get__(self):
|
||||
return self._blocking
|
||||
|
||||
def __set__(self, value):
|
||||
self._blocking = value
|
||||
|
||||
cdef _schedule_callbacks(self):
|
||||
cdef:
|
||||
list callbacks
|
||||
|
|
|
@ -156,8 +156,8 @@ cdef class BaseTask(BaseFuture):
|
|||
# Yielded Future must come from Future.__iter__().
|
||||
if result._loop is not self._loop:
|
||||
self._raise_wrong_loop(result)
|
||||
elif result._blocking:
|
||||
result._blocking = False
|
||||
elif _future_get_blocking(result):
|
||||
_future_set_blocking(result, False)
|
||||
result.add_done_callback(self._wakeup)
|
||||
self._fut_waiter = result
|
||||
if self._must_cancel:
|
||||
|
|
Loading…
Reference in New Issue