Cancel remote async gens when `aclose()` is called

remote_task_cancelling
Tyler Goodlet 2018-12-10 23:13:25 -05:00
parent 4dccb44c67
commit 32c7a06e6a
1 changed files with 3 additions and 1 deletions

View File

@ -139,7 +139,9 @@ class Portal:
"Received internal error at portal?")
raise unpack_error(msg, self.channel)
except StopAsyncIteration:
except GeneratorExit:
# for now this msg cancels an ongoing remote task
await self.channel.send({'cancel': True, 'cid': cid})
log.debug(
f"Cancelling async gen call {cid} to "
f"{self.channel.uid}")