Question: posix fcntl module

Ignacio Vazquez-Abrams ignacio at openservices.net
Wed Aug 29 08:00:22 CEST 2001


On Wed, 29 Aug 2001, Sheila King wrote:

> On Wed, 29 Aug 2001 00:32:00 -0400 (EDT), Ignacio Vazquez-Abrams
> <ignacio at openservices.net> wrote in comp.lang.python in article
> <mailman.999059623.9527.python-list at python.org>:
>
> :On Wed, 29 Aug 2001, Sheila King wrote:
> :
> :> On Tue, 28 Aug 2001 20:02:51 -0400 (EDT), Ignacio Vazquez-Abrams
> :> <ignacio at openservices.net> wrote in comp.lang.python in article
> :> <mailman.999043423.30546.python-list at python.org>:
> :>
> :>  [snip]
> :>
> :> :Also, you should make it so that the file is immediately opened in __init__(),
> :>
> :> Why? I don't see any persuasive reason for that. The methods that I'm
> :> using under windows don't allow for me to separate the action of opening
> :> the file and obtaining the lock (there is a single command which does
> :> both), and I wanted to keep the functions between the windows and the
> :> posix versions as close to parallel as possible. In any case, I can't
> :> see any compelling reason for the file opening to occur in the init
> :> function.
> :
> :I just finished talking with a friend who's done more recent Win32 development
> :than me, and he claims that you can reopen the file (without closing it) using
> :the aforementioned API function again in order to apply a lock. It sounds
> :fishy to me too, but it might be worth a shot.
>
> I'm sorry. You lost me here.
> The windows function I'm using (which was mentioned elsewhere) is
> CreateFile. Whether or not I can reopen the file without having closed
> it is immaterial to my module, since my unlock function closes the file
> and deletes the file handle.
>
> What am I supposed to "give a shot" to???
>
> So far, my windows code is all performing as I expect (not that I've
> shared it here...). That may be partly why I'm confused by this segue
> into discussing the Windows implementation.
>
>
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/

Fair enough. Your code works how you expect it to. But does it work how
_others_ would expect it to? With normal files in Python, one call to open()
opens the file, and then you can immediately read() or write() with it.
There's no need to call a secondary method in order to "activate" it; it just
"works".

I don't know if CreateFile() is the correct API function (my friend couldn't
remember the name, MSDN is pooched as usual, the SDK will take a while to D/L,
and my memory fails me), but the class as written doesn't emulate normal
Python behaviour. If you give me time I can find the API function. It
shouldn't take me that long (and it would help if I could find my copy of VC++
6.0 :( ), so just wait a day or two then I can help you emulate normal files
perfectly.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>





More information about the Python-list mailing list