diff --git a/uvloop/future.pyx b/uvloop/future.pyx index a650872..6d91402 100644 --- a/uvloop/future.pyx +++ b/uvloop/future.pyx @@ -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 diff --git a/uvloop/task.pyx b/uvloop/task.pyx index a000415..ff2e218 100644 --- a/uvloop/task.pyx +++ b/uvloop/task.pyx @@ -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: