xmlstream: handle done tasks in wait_until
and handle other loops properly
This commit is contained in:
parent
370abb1d98
commit
0eed84d0b2
1 changed files with 8 additions and 2 deletions
|
@ -1142,9 +1142,15 @@ class XMLStream(asyncio.BaseProtocol):
|
|||
:param int timeout: Timeout
|
||||
"""
|
||||
fut = asyncio.Future()
|
||||
def result_handler(event_data):
|
||||
if not fut.done():
|
||||
fut.set_result(event_data)
|
||||
else:
|
||||
log.debug("Future registered on event '%s' was alredy done", event)
|
||||
|
||||
self.add_event_handler(
|
||||
event,
|
||||
fut.set_result,
|
||||
result_handler,
|
||||
disposable=True,
|
||||
)
|
||||
return await asyncio.wait_for(fut, timeout)
|
||||
return await asyncio.wait_for(fut, timeout, loop=self.loop)
|
||||
|
|
Loading…
Reference in a new issue