Patches item #1744382, was opened at 2007-06-27 20:08 Message generated for change (Comment added) made by loupgaroublond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1744382&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Modules Group: Python 2.6 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Yaakov Nemoy (loupgaroublond) Assigned to: Nobody/Anonymous (nobody) Summary: Read Write lock Initial Comment: This is a Lock for handling both multiple readers and a single or multiple writers. It allows any number of readers to acquire a 'lock' via a modified semaphore. It also allows any number of writers to try to acquire a lock, which signals the lock to block new readers from acquiring, until the writers have had a chance to do their business. Through a simple lock, multiple writers can wait in line, although only one writer can actually write at a time. It also lets the developer use the 'with' statement, via methods that return contextmanagers. I actually had a couple of unimplemented ideas. A) Writers can specify a deadline (or even use a default) such that after the deadline passes, the lock can use a callback to rollback/kill/pause readers, so that the writer doesn't wait an eternity. B) Allowing the semaphore to have an upper limit of allowed readers (or anythings), Since I don't need it, i never programmed it, but it should be fairly trivial to implement if there is any demand. ---------------------------------------------------------------------- >Comment By: Yaakov Nemoy (loupgaroublond) Date: 2007-07-06 19:51 Message: Logged In: YES user_id=1487908 Originator: YES Out of those four deliverables, i have three (albeit the easiest). Attached is a copy of the newly dubbed ReadWriteLock along with his pal ReverseSemaphore, and two new helper objects ReadLock and WriteLock (can you do the java equivalent of anonymous inner classes?). This is a patch on the copy of threading.py that is delivered with Fedora 7 aka: Version: 2.5 Release: 12.fc7 which was done for convenience (my convenience that is, and certainly not yours ;)) The naming convention has been changed to follow that of Java's, the acquire/release pattern notwithstanding. There is some documentation via docstrings, as I wasn't sure of the best way to document this module. The last point, unit testing, I am not sure as the best way to go about a multithreaded unit test. I can look into it later, but honestly, it's friday, and there are two days left till monday. Please let me know if I am on the right track here at least. Yaakov File Added: threading.py ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2007-06-30 19:38 Message: Logged In: YES user_id=21627 Originator: NO The patch is unacceptable in its current form: - it should be provided as a patch to threading.py, not as a separate module - it should have a name that follows "the convention", which seems to be that it should have "reader" and "writer" in its name (or "rw"). See how C# and Java do it (and other libraries you can find that provide such a mechanism) - it needs documentation - it needs tests. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1744382&group_id=5470 _______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
