Help: using msvcrt for file locking

Ignacio Vazquez-Abrams ignacio at openservices.net
Sat Aug 25 19:58:36 EDT 2001


On Sat, 25 Aug 2001, Sheila King wrote:

> Well, it didn't have any bearing on this question, so I didn't post it.
> But it is my own code (not yet tested). Since you ask, here it is:
>
>  [snip]
>
> And then there is the wrapper class, lockobject:
>
>  [snip]
>

I like. The only suggestion I'm going to make is that instead of passing the
filename to methods of the instantiated object, perhaps passing it when
instantiating it might be better. That way you can keep all the information
about the file on-hand when the locking methods are called. You could also
pass the mode and have a complete replacement for the file object, with
locking added.

> I'm just really dissatisfied with the poor file locking support in
> Python, unless one is writing code exclusively for posix platforms.
> About a week ago, I was composing a rant on that topic to post here. I
> did a lot of research on the topic, and a lot of web searches
> (google.com, groups.google.com, activestate.com, mail.python.org and so
> forth...)
>
> In the end, I decided not to post the rant (I deleted it), since I
> didn't think I'd gain anything by it. I decided to just rather try to
> solve the problem myself.

Good for you. I'm on several mailing lists and there are always people
complaining about a certain feature not being supported, yet they aren't
willing to look into the problem.

> Really, though, I do think the problem should be solved by someone in
> the Python developers circle and included in the standard library
> (something along the lines of anydbm). But, that's just my opinion. I
> have a number of reasons why I feel that way, but I won't go into it
> right now.

One of the problems with freely-available open-source software is that the
developers frequently aren't paid. That puts a limiting factor on how much
time they can spend on a project, because the rest of their time is spent
working and dealing with family.

One of the benefits of open-source software (and of scripting/programming
languages in general) is that the circle of developers is usually not limited
to a small number of people who have to be bugged for everything (even though
they usually are ;) ).

> Anyhow, Ignacio, thanks for the idea about the file descriptor. I think
> you may have something there. I will try it out later tonight and see if
> that helps.
>
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/

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





More information about the Python-list mailing list