Add the loop parameters at places where it has been forgotten

This commit is contained in:
mathieui 2018-10-09 12:34:56 +02:00
parent dda4e18b81
commit 809c500002
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3
4 changed files with 32 additions and 10 deletions

View file

@ -312,7 +312,11 @@ class XEP_0030(BasePlugin):
infos += [
self.get_info(item[0], timeout=timeout, **kwargs)
for item in items]
info_futures, _ = await asyncio.wait(infos, timeout=timeout)
info_futures, _ = await asyncio.wait(
infos,
timeout=timeout,
loop=self.xmpp.loop
)
self.domain_infos[domain] = [
future.result() for future in info_futures]

View file

@ -62,7 +62,10 @@ class XEP_0163(BasePlugin):
for ns in namespace:
self.xmpp['xep_0030'].add_feature('%s+notify' % ns,
jid=jid)
asyncio.ensure_future(self.xmpp['xep_0115'].update_caps(jid))
asyncio.ensure_future(
self.xmpp['xep_0115'].update_caps(jid),
loop=self.xmpp.loop,
)
def remove_interest(self, namespace, jid=None):
"""
@ -81,7 +84,10 @@ class XEP_0163(BasePlugin):
for ns in namespace:
self.xmpp['xep_0030'].del_feature(jid=jid,
feature='%s+notify' % namespace)
asyncio.ensure_future(self.xmpp['xep_0115'].update_caps(jid))
asyncio.ensure_future(
self.xmpp['xep_0115'].update_caps(jid),
loop=self.xmpp.loop,
)
def publish(self, stanza, node=None, id=None, options=None, ifrom=None,
timeout_callback=None, callback=None, timeout=None):

View file

@ -95,7 +95,10 @@ class XEP_0199(BasePlugin):
self.timeout = timeout
self.keepalive = True
handler = lambda event=None: asyncio.ensure_future(self._keepalive(event))
handler = lambda event=None: asyncio.ensure_future(
self._keepalive(event),
loop=self.xmpp.loop,
)
self.xmpp.schedule('Ping keepalive',
self.interval,
handler,

View file

@ -285,7 +285,10 @@ class XMLStream(asyncio.BaseProtocol):
self.disable_starttls = disable_starttls
self.event("connecting")
self._current_connection_attempt = asyncio.ensure_future(self._connect_routine())
self._current_connection_attempt = asyncio.ensure_future(
self._connect_routine(),
loop=self.loop,
)
async def _connect_routine(self):
self.event_when_connected = "connected"
@ -306,7 +309,7 @@ class XMLStream(asyncio.BaseProtocol):
else:
ssl_context = None
await asyncio.sleep(self.connect_loop_wait)
await asyncio.sleep(self.connect_loop_wait, loop=self.loop)
try:
await self.loop.create_connection(lambda: self,
self.address[0],
@ -321,7 +324,10 @@ class XMLStream(asyncio.BaseProtocol):
log.debug('Connection failed: %s', e)
self.event("connection_failed", e)
self.connect_loop_wait = self.connect_loop_wait * 2 + 1
self._current_connection_attempt = asyncio.ensure_future(self._connect_routine())
self._current_connection_attempt = asyncio.ensure_future(
self._connect_routine(),
loop=self.loop,
)
def process(self, *, forever=True, timeout=None):
"""Process all the available XMPP events (receiving or sending data on the
@ -336,10 +342,10 @@ class XMLStream(asyncio.BaseProtocol):
else:
self.loop.run_until_complete(self.disconnected)
else:
tasks = [asyncio.sleep(timeout)]
tasks = [asyncio.sleep(timeout, loop=self.loop)]
if not forever:
tasks.append(self.disconnected)
self.loop.run_until_complete(asyncio.wait(tasks))
self.loop.run_until_complete(asyncio.wait(tasks, loop=self.loop))
def init_parser(self):
"""init the XML parser. The parser must always be reset for each new
@ -781,7 +787,10 @@ class XMLStream(asyncio.BaseProtocol):
old_exception(e)
else:
self.exception(e)
asyncio.ensure_future(handler_callback_routine(handler_callback))
asyncio.ensure_future(
handler_callback_routine(handler_callback),
loop=self.loop,
)
else:
try:
handler_callback(data)