2006/11/21, Patrick O'Brien <[EMAIL PROTECTED]>:
> What would one use in IronPython to get the equivalent of fcntl.flock() or
> win32file.LockFileEx()?
.NET's FileStream has Lock() and Unlock() methods, but I don't know
how to apply these to IronPython file object. Any idea?
One could use P/Invoke too.
Example IronPython code:
from System.IO import FileStream, FileMode
f = FileStream('test', FileMode.Open)
f.Lock(0, f.Length)
raw_input()
f.Unlock(0, f.Length)
Above is roughly equivalent to following CPython/Unix code:
import fcntl
f = open('test', 'w')
fcntl.lockf(f, fcntl.LOCK_EX|fcntl.LOCK_NB)
raw_input()
fcntl.lockf(f, fcntl.LOCK_UN)
--
Seo Sanghyeon
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com