Created
October 30, 2018 07:20
-
-
Save Disassembler0/3297f4f4e86a95507265d45192f3e0bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from threading import Lock | |
| @contextmanager | |
| def nonblocking(lock=Lock()): | |
| locked = lock.acquire(False) | |
| try: | |
| yield locked | |
| finally: | |
| if locked: | |
| lock.release() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment