如果您需要锁(以避免Joonas描述的竞争条件),并且坚持使用Python 2.4,
import threadinglock = threading.Lock()shared_dict = {}def do_thing(user, value): lock.acquire() try: shared_dict[user] = value finally: # Always called, even if exception is raised in try block lock.release()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)