测试函数是否是线程安全的

时间:2014-03-12 10:07:40

标签: python

我有这样的功能

def party_id_generator(size=6, chars=string.ascii_uppercase + string.digits):
    party_ids = []
    seen = set()
    while len(party_ids) < 2:
        party_id_str = ''.join(random.choice(string.ascii_uppercase) for x in range(5))
        party_id_dig = ''.join(random.choice(string.digits) for x in range(3))
        party_id = ''.join([party_id_str,party_id_dig])
        if party_id in seen:
            continue
        seen.add(party_id)
        party_ids.append(party_id)
    return party_ids

我怎么知道函数是否是线程安全的?

0 个答案:

没有答案