Cross Platform Locking: THe Easy Way
Jerome Chan
eviltofu at rocketmail.com
Sun Oct 29 10:59:47 EST 2000
More information about the Python-list mailing list
Sun Oct 29 10:59:47 EST 2000
- Previous message (by thread): Cross Platform Locking: THe Easy Way
- Next message (by thread): Cross Platform Locking: THe Easy Way
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <mailman.972831527.7418.python-list at python.org>, Moshe Zadka <moshez at math.huji.ac.il> wrote: > OK, here's an easy way to do crossplafrom locking: > Run the following Python script, and then > > 1) To lock, use urllib to grab the "/lock" url > 2) To unlick , use urllib to grab the "/unlock" url > > You need to get this to run on system startup. > On UNIX, put it in rc.d. > On NT, do whatever it is NT guys do <wink> > > #Released to the public domain by Moshe zadka > import BaseHTTPServer > > locked = 0 > > class LockHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): > > def do_GET(self): > if self.path=="/lock": > return self.lock() > if self.path=="/unlock": > return self.unlock() > self.send_error(404, "Only locking") > > def lock(self): > global locked > if locked: > self.send_error(403, "Already locked") > else: > locked = 1 > self.send_response(202) > self.end_headers() > > def unlock(self): > global locked > if not locked: > self.send_error(403, "Not locked") > else: > locked = 0 > self.send_response(202) > self.end_headers() > > def test(HandlerClass = LockHTTPRequestHandler, > ServerClass = BaseHTTPServer.HTTPServer): > BaseHTTPServer.test(HandlerClass, ServerClass) > > > if __name__ == '__main__': > test() > > -- > Moshe Zadka <moshez at math.huji.ac.il> -- 95855124 > http://advogato.org/person/moshez > > What if I want to lock and unlock on different files? Or different sections of a file?
- Previous message (by thread): Cross Platform Locking: THe Easy Way
- Next message (by thread): Cross Platform Locking: THe Easy Way
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list