Fix iterate_per_tenants and adds docstring

Set lookup should be more efficient than List

Change-Id: I4605274022b48b44d426262e096543eb92d9a6bd
This commit is contained in:
Yair Fried 2015-03-02 14:19:04 +02:00
parent 8995027941
commit 419ad82bed

View File

@ -433,10 +433,15 @@ def retry(times, func, *args, **kwargs):
def iterate_per_tenants(users):
processed_tenants = list()
"""Iterate of a single arbitrary user from each tenant
:type users: list of users
:return: iterator of a single user from each tenant
"""
processed_tenants = set()
for user in users:
if user["tenant_id"] not in processed_tenants:
processed_tenants.append(user["tenant_id"])
processed_tenants.add(user["tenant_id"])
yield (user, user["tenant_id"])