Using portalocker
we can lock a file for access through the following way:
f=open("M99","r+")
portalocker.lock(f,portalocker.LOCK_EX)
The lock
over the file can be removed using
f.close() #or
portalocker.unlock(file) #needs `file` ie reference to file it locked ..pretty obvious too
Can this same thing be done by any other way in python wherein
We can lock the file for access
Forget the reference to file or forget
f
in this case and using onlyfilename
i.eM99
in this case detect if it has alock
andunlock
it.
I cannot save f
or file object
so cant use pickle
or something as well.Is there a way using python
or some win32api
or something?
Sort of make this asynchronous
somehow?
Aucun commentaire:
Enregistrer un commentaire