Skip to content

Commit

Permalink
Update type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Loren Arthur committed Aug 3, 2019
1 parent 18f1bda commit 8345ecd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 6 additions & 7 deletions tornado/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,13 @@ async def run(self) -> None:
future = self.future
if future is None:
raise Exception("No pending future")
if not self.future.done():
if not self.future.done(): # type: ignore
_step = asyncio.Event()

def step(*args):
def step(f: "Future[_T]") -> None:
_step.set()

self.io_loop.add_future(self.future, step)
self.io_loop.add_future(self.future, step) # type: ignore
await _step.wait()
self.future = None
try:
Expand Down Expand Up @@ -747,18 +747,17 @@ def step(*args):
if self.future is moment:
await sleep(0)

def handle_yield(self, yielded: _Yieldable) -> bool:
def handle_yield(self, yielded: _Yieldable) -> None:
try:
self.future = convert_yielded(yielded)
except BadYieldError:
self.future = Future()
future_set_exc_info(self.future, sys.exc_info())

def finish(self, future):
def finish(self, future: "Future[_T]") -> None:
if future.cancelled():
self.task.cancel()
self.future.cancel()
self.task = None
self.future.cancel() # type: ignore


# Convert Awaitables into Futures.
Expand Down
8 changes: 5 additions & 3 deletions tornado/ioloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,11 @@ def run() -> None:
future_cell[0] = fut
fut.set_result(result)
assert future_cell[0] is not None
self.add_future(
future_cell[0], lambda f: f.add_done_callback(lambda _: self.stop())
)

def _stop(f: "Future[_T]") -> None:
f.add_done_callback(lambda _: self.stop())

self.add_future(future_cell[0], _stop)

self.add_callback(run)
if timeout is not None:
Expand Down

0 comments on commit 8345ecd

Please sign in to comment.