XEP-0030: Don’t call the timeout_callback on each domain which doesn’t reply to disco#info.
This commit is contained in:
parent
bd22a41a78
commit
e241d4e3c7
2 changed files with 10 additions and 11 deletions
|
@ -299,18 +299,18 @@ class XEP_0030(BasePlugin):
|
|||
return self.api['has_identity'](jid, node, ifrom, data)
|
||||
|
||||
async def get_info_from_domain(self, domain=None, timeout=None,
|
||||
cached=True, callback=None, **kwargs):
|
||||
cached=True, callback=None):
|
||||
if domain is None:
|
||||
domain = self.xmpp.boundjid.domain
|
||||
|
||||
if not cached or domain not in self.domain_infos:
|
||||
infos = [self.get_info(
|
||||
domain, timeout=timeout, **kwargs)]
|
||||
domain, timeout=timeout)]
|
||||
iq_items = await self.get_items(
|
||||
domain, timeout=timeout, **kwargs)
|
||||
domain, timeout=timeout)
|
||||
items = iq_items['disco_items']['items']
|
||||
infos += [
|
||||
self.get_info(item[0], timeout=timeout, **kwargs)
|
||||
self.get_info(item[0], timeout=timeout)
|
||||
for item in items]
|
||||
info_futures, _ = await asyncio.wait(
|
||||
infos,
|
||||
|
@ -319,7 +319,7 @@ class XEP_0030(BasePlugin):
|
|||
)
|
||||
|
||||
self.domain_infos[domain] = [
|
||||
future.result() for future in info_futures]
|
||||
future.result() for future in info_futures if not future.exception()]
|
||||
|
||||
results = self.domain_infos[domain]
|
||||
|
||||
|
|
|
@ -67,10 +67,9 @@ class XEP_0363(BasePlugin):
|
|||
def _handle_request(self, iq):
|
||||
self.xmpp.event('http_upload_request', iq)
|
||||
|
||||
async def find_upload_service(self, domain=None, timeout=None, timeout_callback=None):
|
||||
async def find_upload_service(self, domain=None, timeout=None):
|
||||
results = await self.xmpp['xep_0030'].get_info_from_domain(
|
||||
domain=domain,
|
||||
timeout=timeout, timeout_callback=timeout_callback)
|
||||
domain=domain, timeout=timeout)
|
||||
|
||||
candidates = []
|
||||
for info in results:
|
||||
|
@ -101,8 +100,7 @@ class XEP_0363(BasePlugin):
|
|||
''' Helper function which does all of the uploading process. '''
|
||||
if self.upload_service is None:
|
||||
info_iq = await self.find_upload_service(
|
||||
domain=domain,
|
||||
timeout=timeout, timeout_callback=timeout_callback)
|
||||
domain=domain, timeout=timeout)
|
||||
if info_iq is None:
|
||||
raise UploadServiceNotFound()
|
||||
self.upload_service = info_iq['from']
|
||||
|
@ -133,7 +131,8 @@ class XEP_0363(BasePlugin):
|
|||
|
||||
basename = os.path.basename(filename)
|
||||
slot_iq = await self.request_slot(self.upload_service, basename, size,
|
||||
content_type, ifrom, timeout)
|
||||
content_type, ifrom, timeout,
|
||||
timeout_callback=timeout_callback)
|
||||
slot = slot_iq['http_upload_slot']
|
||||
|
||||
headers = {
|
||||
|
|
Loading…
Reference in a new issue