Skip to content

Instantly share code, notes, and snippets.

View TaeWoo21's full-sized avatar

Taewoo Lee TaeWoo21

View GitHub Profile
@lemiant
lemiant / ReadWriteLock.py
Last active May 12, 2022 08:26
Reader Biased ReadWriteLock in Python
import threading
class ReadWriteLock(object):
""" An implementation of a read-write lock for Python.
Any number of readers can work simultaneously but they
are mutually exclusive with any writers (which can
only have one at a time).
This implementation is reader biased. This can be harmful
under heavy load because it can starve writers.
However under light load it will be quite perfomant since