Datasets:
| def exclusive(via=threading.Lock): | |
| """pass""" | |
| def make_exclusive(fnc): | |
| fnc_guard = via() | |
| def exclusive_call(*args, **kwargs): | |
| if fnc_guard.acquire(blocking=False): | |
| try: | |
| return fnc(*args, **kwargs) | |
| finally: | |
| fnc_guard.release() | |
| else: | |
| raise RuntimeError('exclusive call to %s violated') | |
| return exclusive_call | |
| return make_exclusive |