The protection of resources

Skip Montanaro skip at pobox.com
Mon Jul 28 14:31:16 CEST 2003


    Krisztian> So these my questions:
    Krisztian> - 1. How to use the py mutex object ? Please send an example
    Krisztian>      to me ! 

    Krisztian> - 2. Have the py an signal object ? (platform !!!) 

    Krisztian> - 3. Is any solution is a file locking.  Have the py a
    Krisztian>      possibility of exclusive file opening ?

Yes.  Look at the docs for os.open.  There's an EXCLusive flag which should
work on Windows as well as Unix I think.  This will work across processes as
well a threads, but see below if all you're interested in is a single
multi-threaded application.

I think you'll often find it easier to use the Queue object to protect
shared resources.  Just create the queue and put() the shared resource on
the queue, then get() it when you need it and put() it back when you're done
with it.

Skip






More information about the Python-list mailing list