Skip to content

Commit

Permalink
update asset lit for concurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy committed Jun 20, 2024
1 parent 45796f7 commit 0c20107
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions api/terminal/terminal/apps/assets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import os.path
import re
import concurrent.futures

import ipaddress
from talos.common import cache
Expand Down Expand Up @@ -147,10 +148,18 @@ def list(self,
CONF.asset.asset_field_password: 'password',
CONF.asset.asset_field_desc: 'description'
}
for permission in permissions:
expression_assets = self.list_asset_by_expression(permission['expression'], fields)
auth_asset_ids.extend([auth_asset['asset_id'] for auth_asset in permission['assets']])
auth_asset_ids.extend([asset['id'] for asset in expression_assets])
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
futures = [executor.submit(self.list_asset_by_expression, permission['expression'], fields)
for permission in permissions]
for future in concurrent.futures.as_completed(futures):
expression_assets = future.result()
auth_asset_ids.extend([asset['id'] for asset in expression_assets])
for permission in permissions:
auth_asset_ids.extend([auth_asset['asset_id'] for auth_asset in permission['assets']])
# for permission in permissions:
# expression_assets = self.list_asset_by_expression(permission['expression'], fields)
# auth_asset_ids.extend([auth_asset['asset_id'] for auth_asset in permission['assets']])
# auth_asset_ids.extend([asset['id'] for asset in expression_assets])
auth_asset_ids = set(auth_asset_ids)

datas = []
Expand Down

0 comments on commit 0c20107

Please sign in to comment.