Sign in to follow this  
Followers 0
LiquidFire

File in use while open for writing

8 posts in this topic

Hi,

Recently I upgraded to the latest version of AutoIt (the one I was using was at least half a year old, not sure which one it was exactly). My code runs fine with the new version, but I noticed a change in behaviour when opening files for writing.

Some of my scripts open a log file and periodically write to it. With the latest version of AutoIt, while the file is open for writing I can't open it (even read-only) with another program.

A simple demonstration of the problem:

Local $file = FileOpen("test.txt", 1)
FileWriteLine($file, "1")
Sleep(10000) ; while it's waiting, try to open the file with e.g. notepad - it will say it's being used by another process
FileWriteLine($file, "2")
FileClose($file)

This makes it impossible to look at my log files until the script has finished running. Is there any way to open the file for writing without locking it?

The only reason I updated to the latest version was so I could use FileFlush, but that's useless if I can't look at the file at all!

Any help is appreciated.

Share this post


Link to post
Share on other sites



There was a recent discussion about this issue. I personnally believe this is a regression due to changed flags within FileOpen. Developpers could consider looking closer to the issue if people affected would comment again on the existing (similar but not identically phrased) ticket. See this thread.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Thanks for the response. I'll go comment on the bugs.

Do you know of any workarounds currently?

I guess I could just downgrade to 3.3.2.0 since it has FileFlush, but supposedly doesn't yet have this "bug fix".

Share this post


Link to post
Share on other sites

That's the whole extent of my knowledge. Perhaps v3.3.2.0 will be fine for you in the interim.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

You could use a text file editor/viewer that is capable of opening files in read mode that other applications have locked for writing. TextPad and UltraEdit are 2 of many that come to mind. Notepad needs to be able to lock a file before it will open it.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Nothing seems to be able to open the file while it's opened for writing (and I need to be able to read it from a Python script, not a text editor anyway).

However, I posted a comment in the bug tracker and apparently it works again in the latest betas (since 3.3.5.3).

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks for the suggestions, picaxe. The resulting file handle wouldn't work with AutoIt's File* functions though, would it? I think I'll just use the beta or older version where this isn't a problem, rather than rewrite my code to use WinAPI directly.

Edited by LiquidFire

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0