File locking

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
HarryH
User
Beiträge: 266
Registriert: Freitag 23. Mai 2003, 09:08
Wohnort: Deutschland

Hi,

Habe gerade das Modul 'msvcrt' in der Python-Doku gefunden.
Ist nur für Windows zu verwenden, bietet aber die Möglichkeit ein Datei zu sperren.
Es gibt dort folgende Funktion:
=> locking( fd, mode, nbytes)

Dabei gibt es fünf verschiedene Modi auszuwählen:
LK_LOCK
LK_RLCK

LK_NBLCK
LK_NBRLCK

LK_UNLCK
Doch was ist der Unterschied zwischen LK_LOCK und LK_RLCK, bzw. zwischen LK_NBLCK und LK_NBRLCK ?
Aus der Doku scheint das nicht hervorzugehen.
Vielleicht könnte mir von euch das einer erklären?
Danke!
Gruß, Harry
Leonidas
Python-Forum Veteran
Beiträge: 16025
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Hier ist es ein wenig detailierter erkärt. Soweit ich das verstehe, dürfen andere Prozesse die Datei dann noch lesen.
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
HarryH
User
Beiträge: 266
Registriert: Freitag 23. Mai 2003, 09:08
Wohnort: Deutschland

Hi Leonidas,

Der von dir beigefügte Link funktioniert bei mir leider nicht. :roll:
Gruß, Harry
Leonidas
Python-Forum Veteran
Beiträge: 16025
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Sowas.. bei mir geht er, aber hier mal der Ausschnitt:
LK_UNLCK 0
Unlocks the specified region. The calling process releases a region of the file it had previously locked.

LK_LOCK 1
Locks the specified region. The calling process sleeps until the entire region is available if any part of it has been locked by a different process. The region is then locked for the calling process and no other process may read or write in any part of the locked region. (lock against read and write).

LK_NBLCK 2
Locks the specified region. If any part of the region is already locked by a different process, EACCES is returned instead of waiting for the region to become available for locking (nonblocking lockrequest).

LK_RLCK 3
Same as LK_LOCK except that the locked region may be read by other processes (read permitted lock).

LK_NBRLCK 4
Same as LK_NBLCK except that the locked region may be read by other processes (nonblocking, read permitted lock).
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
Antworten