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
1)We can lock the file for access
2)Forget the reference to file or forget f
in this case and using only filename
i.e M99
in this case detect if it has a lock
and unlock
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