Skip to main content
Hi,

 

 

I am using a WorkspaceRunner to run another workspace a number of times.  Because the workspace I'm calling uses up a lot of memory, I was wondering if there is a transformer that I can add to the called workspace, so that at the end of each run, the temporary files are purged automatically?

 

 

Thanks,
Hi,

 

 

I don't think there is such a transformer.

 

FME itself has a functionality to delete automatically temp files after completion of a translation. And I don't think that the size of temp files affects so much to performance of the translation, unless overflowing disk size.

 

So I don't worry about that.

 

 

This article may be helpful.

 

Why did the temporary files not get deleted from my translation? (http://fmepedia.safe.com/articles/FAQ/Why-did-the-temporary-files-not-get-deleted-from-my-translation)

 

 

Takashi
there is a manual purg button on the menu of Workbench.

 

Tools->purge. But there is no automated option afaik.
This is a shutdown script example to try removing all the temporary files and folders in the FME_TEMP folder.

 

I cannot guarantee that it always works safely.

 

-----

 

# Shutdown Python Script Example

 

import os

 

 

# Try removing a file/directory specified by the path.

 

# If the path indicates a directory, it removes recursively

 

# all subdirectories and files under the directory.

 

def rmfile(path):

 

    if os.path.isfile(path):

 

        try:

 

            os.remove(path)

 

        except:

 

            pass

 

    else:

 

        map(rmfile, Â'%s/%s' % (path, f) for f in os.listdir(path)])

 

        try:

 

            os.rmdir(path)

 

        except:

 

            pass

 

 

# Get FME_TEMP directory path from environment variable.

 

# If it exists, try removing all temporary files and folders.

 

tmp = os.environ.get('FME_TEMP')

 

if tmp != None:

 

    map(rmfile, n'%s/%s' % (tmp, f) for f  in os.listdir(tmp)])

 

-----

 

 

Tcl too can do that concisely.

 

-----

 

# Shutdown Tcl Script Example

 

proc rmfile {path} {

 

    if { 

        foreach f mglob -directory $path -type {f d} *] {rmfile $f}

 

    }

 

    catch {file delete $path}

 

}

 

 

if {!{catch {set tmp $env(FME_TEMP)}]} {

 

    foreach f eglob -directory $tmp -type {f d} *] {rmfile $f}

 

}

 

-----
The shutdown script certainly removes every unlocked file in the Temp folder, including temporary source files for Views of Data Inspector. So the Views showing translation results may become invalid immediately after running the script.

 

That's a side-effect. If you cannot accept it, the script should not be used.

Reply