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
fin this case and using onlyfilenamei.eM99in this case detect if it has alockandunlockit.
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