I experienced the following issue when using the Audacity scripting environment for python. It creates a temporary file where one can write commands that are to be executed by Audacity. The two relevant files are being create upon Audacity launch.
My script contains the following snippet (original source):
# Initialize variable depending on os:
if sys.platform == 'win32':
print("pipe-test.py, running on windows")
TONAME = '\\\\.\\pipe\\ToSrvPipe'
FROMNAME = '\\\\.\\pipe\\FromSrvPipe'
# Check if temp files actually exist
if not os.path.exists(TONAME):
print(" ..does not exist. Ensure Audacity is running with mod-script-pipe.")
sys.exit()
Everything fine so far, the file is found. Then I tried to open it, and the operation failed every time. I did some tweaking here and there, but eventually found this strange behavior indicating that opening the file was not the problem, but the exists()
check. I changed my code like this:
# Initialize variable depending on os:
[...]
# Check if temp files actually exist (it exists)
if not os.path.exists(TONAME):
print(" ..does not exist. Ensure Audacity is running with mod-script-pipe.")
sys.exit()
# Check if temp files actually exist (it is gone)
if not os.path.exists(TONAME):
print("File is gone now")
sys.exit()
The second check would tell me that the file suddenly disappeared after I just checked for its existence. How is this possible? How is it possible that os.path.exists()
deleted my temporary file?