Hello python-list,
On windows I try with this:
import os
f1=file('a',"w+",os.O_EXCL|os.O_WRONLY)
f1.write("0")
f2=file('a',"w+",os.O_EXCL|os.O_WRONLY)
f2.write("1")
f1.close()
f2.close()
But it is not working...
So how to I lock this file to prevent from next opening ?
Thanx.
--
Best regards,
fowlertrainer mailto:fo***********@anonym.hu 2 1509 fo***********@anonym.hu fed this fish to the penguins on Friday 28
November 2003 03:30 am: On windows I try with this:
import os f1=file('a',"w+",os.O_EXCL|os.O_WRONLY)
But it is not working...
So how to I lock this file to prevent from next opening ?
First step: read the documentation for file() (section 2.1 of the
Library reference)
file(filename[, mode[, bufsize]])
Does anything in that definition imply being able to set locking?
Hint, anything that is a builtin to Python is unlikely to be using
constants defined in an imported module.
Second step: read the documentation for the os module (6.1.3 in my
copy).
open(file, flags[, mode])
In short, you are trying to mix flags from two separate types of file
operations.
-- ================================================== ============ < wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < ================================================== ============ < Bestiaria Home Page: http://www.beastie.dm.net/ < Home Page: http://www.dm.net/~wulfraed/ <
Hello, f1=file('a',"w+",os.O_EXCL|os.O_WRONLY)
Have a look at the documentation, the 3'rd parameter to "file" is the buffer size.
So how to I lock this file to prevent from next opening ?
Use os.open or the win32all package (with CreateFile).
HTH.
Miki This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Antoon Pardon |
last post by:
The queue and condition class allow threads to wait only a limited
time. However this currently is implemented by a polling loop.
Now for those who like to avoid polling I have here a Tlock...
|
by: John |
last post by:
I've got multiple threads and processes that write to same
file. Before writing all threads / processes first lock
part of file and then write to file. If one thread /
process locks file, another...
|
by: John Bailo |
last post by:
I'm seeing some odd locking behavior when using an DB2400 database and
running an ado.net transaction. My code -- in simplified form, appears
at the bottom.
I want to run several INSERT...
|
by: John Bailo |
last post by:
I'm seeing some odd locking behavior when using an DB2400 database and
running an ado.net transaction. My code -- in simplified form, appears
at the bottom.
I want to run several INSERT...
|
by: Andrew Dowding |
last post by:
Hi Everybody,
I have been looking at problems with my Windows Forms C# application
and it's little Jet 4 (Access) database for the last few days. The
Windows Forms app implements a facade and...
|
by: Gary Nelson |
last post by:
Anyone have any idea why this code does not work?
FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary,
OpenAccess.ReadWrite, OpenShare.Shared)
Dim X As Integer
For X = 1 To 26
FilePut(1, Chr(X +...
|
by: muttu2244 |
last post by:
hi all
am trying to write some information into the file, which is located in
ftp, and this file can be updated by number of people, but if at all i
download a file from the ftp to my local...
|
by: Elmo Mäntynen |
last post by:
Is there something better than using fnctl? It seems a bit intimidating
with a quick look.
|
by: pgdown |
last post by:
Hi,
I have several processes accessing files from one folder, but only
one process should ever access each file. Once one process has the
file, no other process should be allowed to access it,...
|
by: WingSiu |
last post by:
I am writing a Logging util for my ASP.NET application.
I am facing mulit process problem.
I developed a class LogFactory, and have a method called Get_Logger to
create a FileLogger, which will...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |