Merge branch 'remove-loop-wait-for' into 'master'
xmlstream: remove loop parameter to wait_for See merge request poezio/slixmpp!137
This commit is contained in:
commit
35c68738a7
@ -533,7 +533,6 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
await asyncio.wait_for(
|
await asyncio.wait_for(
|
||||||
self.waiting_queue.join(),
|
self.waiting_queue.join(),
|
||||||
wait,
|
wait,
|
||||||
loop=self.loop
|
|
||||||
)
|
)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
wait = 0 # we already consumed the timeout
|
wait = 0 # we already consumed the timeout
|
||||||
@ -1182,20 +1181,25 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
|
|
||||||
:param str event: Event to wait on.
|
:param str event: Event to wait on.
|
||||||
:param int timeout: Timeout
|
:param int timeout: Timeout
|
||||||
|
:raises: :class:`asyncio.TimeoutError` when the timeout is reached
|
||||||
"""
|
"""
|
||||||
fut = asyncio.Future()
|
fut = asyncio.Future()
|
||||||
|
|
||||||
def result_handler(event_data):
|
def result_handler(event_data):
|
||||||
if not fut.done():
|
if not fut.done():
|
||||||
fut.set_result(event_data)
|
fut.set_result(event_data)
|
||||||
else:
|
else:
|
||||||
log.debug("Future registered on event '%s' was alredy done", event)
|
log.debug(
|
||||||
|
"Future registered on event '%s' was alredy done",
|
||||||
|
event
|
||||||
|
)
|
||||||
|
|
||||||
self.add_event_handler(
|
self.add_event_handler(
|
||||||
event,
|
event,
|
||||||
result_handler,
|
result_handler,
|
||||||
disposable=True,
|
disposable=True,
|
||||||
)
|
)
|
||||||
return await asyncio.wait_for(fut, timeout, loop=self.loop)
|
return await asyncio.wait_for(fut, timeout)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def event_handler(self, event: str, handler: Callable):
|
def event_handler(self, event: str, handler: Callable):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user