Question
Norman W. Freeman · Oct 12, 2022

How to check if on a file on a network shared folder is available/exists with a timeout ?

I use the following code to check the last modified date of file which is on a network shared folder (eg: "\\someserver\subfolder\foobar.txt")

set file = ##class(%File).%New(filePath)
set lastModifiedDate = file.DateModified //might hang up for a very long time 
set file = "" //close file

if the file is not available or does not exists, DateModified property return a negative value (which is fine). I use that property to quickly check if file has been modified and need to be imported.

Here is the issue: sometimes, accessing DateModified property will hang up for a long time (about 5 minutes) which is unacceptable in my case. It usually occurs because of some network issue (eg: server not available).

I have tried the following : 

set file = ##class(%File).%New(filePath)
if file.Open("R", 5) //5 seconds timeout, but still hang up
{
   //file is available
}
set file = ""

 and this

OPEN filePath:("R"):5 //might also hang up for several minutes
IF $TEST
{
   //...
}
CLOSE filePath

or this 

if ##class(%File).Exists(filePath)
{
   //...
}

It does not improve anything and still hang up. The 5 seconds timeout works only with local files.

It looks like the timeout is more "how long to wait until the file is created or become available" rather than "maximum time the related I/O operation should take before giving up".

I have in mind to start a job and wait for some amount of time and kill it if necessary but since (AFAIK) each job call spawn a new process I am not sure it's a good idea.

Any suggestions ?

Product version: IRIS 2021.1
$ZV: IRIS for Windows (x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:39:22 EDT
0
0 230
Discussion (2)2
Log in or sign up to continue

I think this has something to do with ECP timeout. Please start management portal and check System -> Configuration -> ECP settings.
Default timeout = 1200 seconds (maybe you'll find there a value of 600).

The problem has nothing in common with Cache or IRIS, it's an OS setting. If a network drive is not available (for example the target is switched off), Windows waits an half an eternity.

You have to ask your sysadmin or Google, providing your Windows version. The very first hit I found is this but it's somewhat old.