Skip to content
Snippets Groups Projects
Commit b86bc2ce authored by inso's avatar inso
Browse files

Fasten wot graph generation with asyncio.gather

parent cf9514bb
No related branches found
No related tags found
No related merge requests found
...@@ -85,12 +85,16 @@ class ExplorerGraph(BaseGraph): ...@@ -85,12 +85,16 @@ class ExplorerGraph(BaseGraph):
certifier_list, certified_list = await asyncio.gather(certifier_coro, certified_coro) certifier_list, certified_list = await asyncio.gather(certifier_coro, certified_coro)
await self.add_certifier_list(certifier_list, current_identity, identity) certifier_coro = asyncio.ensure_future(self.add_certifier_list(certifier_list,
current_identity, identity))
logging.debug("New identity certifiers : {pubkey}".format(pubkey=current_identity.pubkey[:5])) logging.debug("New identity certifiers : {pubkey}".format(pubkey=current_identity.pubkey[:5]))
self.graph_changed.emit() certified_coro = asyncio.ensure_future(self.add_certified_list(certified_list,
await self.add_certified_list(certified_list, current_identity, identity) current_identity, identity))
certifier_coro.add_done_callback(lambda f: self.graph_changed.emit())
certified_coro.add_done_callback(lambda f: self.graph_changed.emit())
await asyncio.gather(certifier_coro, certified_coro)
logging.debug("New identity certified : {pubkey}".format(pubkey=current_identity.pubkey[:5])) logging.debug("New identity certified : {pubkey}".format(pubkey=current_identity.pubkey[:5]))
self.graph_changed.emit()
for cert in certified_list + certifier_list: for cert in certified_list + certifier_list:
if cert['identity'] not in explorable[step + 1]: if cert['identity'] not in explorable[step + 1]:
......
...@@ -22,15 +22,21 @@ class WoTGraph(BaseGraph): ...@@ -22,15 +22,21 @@ class WoTGraph(BaseGraph):
self.add_identity(center_identity, node_status) self.add_identity(center_identity, node_status)
# create Identity from node metadata # create Identity from node metadata
certifier_list = await center_identity.unique_valid_certifiers_of(self.app.identities_registry, certifier_coro = asyncio.ensure_future(center_identity.unique_valid_certifiers_of(self.app.identities_registry,
self.community) self.community))
certified_list = await center_identity.unique_valid_certified_by(self.app.identities_registry, certified_coro = asyncio.ensure_future(center_identity.unique_valid_certified_by(self.app.identities_registry,
self.community) self.community))
certifier_list, certified_list = await asyncio.gather(certifier_coro, certified_coro)
# populate graph with certifiers-of # populate graph with certifiers-of
await self.add_certifier_list(certifier_list, center_identity, account_identity) certifier_coro = asyncio.ensure_future(self.add_certifier_list(certifier_list,
center_identity, account_identity))
# populate graph with certified-by # populate graph with certified-by
await self.add_certified_list(certified_list, center_identity, account_identity) certified_coro = asyncio.ensure_future(self.add_certified_list(certified_list,
center_identity, account_identity))
await asyncio.gather(certifier_coro, certified_coro)
async def get_shortest_path_to_identity(self, account_identity, to_identity): async def get_shortest_path_to_identity(self, account_identity, to_identity):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment