xmlstream: add a wrap() method for ensure_future
This commit is contained in:
parent
5f9ab45a5e
commit
8da5310ea6
1 changed files with 11 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
||||||
# :license: MIT, see LICENSE for more details
|
# :license: MIT, see LICENSE for more details
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
Coroutine,
|
||||||
Callable,
|
Callable,
|
||||||
Iterable,
|
Iterable,
|
||||||
Iterator,
|
Iterator,
|
||||||
|
@ -1251,3 +1252,13 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
self.del_event_handler(event, handler)
|
self.del_event_handler(event, handler)
|
||||||
|
|
||||||
|
def wrap(self, coroutine: Coroutine[Any, Any, Any]) -> Future:
|
||||||
|
"""Make a Future out of a coroutine with the current loop.
|
||||||
|
|
||||||
|
:param coroutine: The coroutine to wrap.
|
||||||
|
"""
|
||||||
|
return asyncio.ensure_future(
|
||||||
|
coroutine,
|
||||||
|
loop=self.loop,
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue