Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_misc_identity.py @ 4372:ec9583cac6c2 default tip
plugin identity: add a timeout when getting identities.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 15 May 2025 17:45:19 +0200 |
parents | ff88a807852d |
children |
comparison
equal
deleted
inserted
replaced
4371:ed683d56b64c | 4372:ec9583cac6c2 |
---|---|
18 from collections import namedtuple | 18 from collections import namedtuple |
19 import io | 19 import io |
20 from pathlib import Path | 20 from pathlib import Path |
21 from base64 import b64encode | 21 from base64 import b64encode |
22 import hashlib | 22 import hashlib |
23 from typing import Any, Coroutine, Dict, List, Optional, Union | 23 from typing import Any, Coroutine, Dict, List, Optional, Union, cast |
24 | 24 |
25 from twisted.internet import defer, threads | 25 from twisted.internet import defer, reactor, threads |
26 from twisted.internet.interfaces import IReactorCore | |
26 from twisted.words.protocols.jabber import jid | 27 from twisted.words.protocols.jabber import jid |
27 | 28 |
28 from libervia.backend.core import exceptions | 29 from libervia.backend.core import exceptions |
29 from libervia.backend.core.constants import Const as C | 30 from libervia.backend.core.constants import Const as C |
30 from libervia.backend.core.i18n import _ | 31 from libervia.backend.core.i18n import _ |
788 entity=entity_jid, | 789 entity=entity_jid, |
789 metadata_filter=metadata_filter, | 790 metadata_filter=metadata_filter, |
790 ) | 791 ) |
791 ) | 792 ) |
792 ) | 793 ) |
793 identities_result = await defer.DeferredList(get_identity_list) | 794 deferred_list = defer.DeferredList(get_identity_list) |
795 deferred_list.addTimeout(5, cast(IReactorCore, reactor)) | |
796 identities_result = await deferred_list | |
794 for idx, (success, identity) in enumerate(identities_result): | 797 for idx, (success, identity) in enumerate(identities_result): |
795 entity_jid = entities[idx] | 798 entity_jid = entities[idx] |
796 if not success: | 799 if not success: |
797 log.warning(f"Can't get identity for {entity_jid}") | 800 log.warning(f"Can't get identity for {entity_jid}") |
798 else: | 801 else: |