Project

General

Profile

Python bindings and temp files

Added by Anonymous about 10 years ago

Hi,

it appears that omitting the output keyword in the python interface to cdo can lead to a problem with temp-files cluttering
the file system. For example a command like this:

ta = np.squeeze(cdo.copy(input=ifile, options='-f nc', returnMaArray='ta'))

will then provoke an exception:

Exception AttributeError: "'NoneType' object has no attribute 'path'" in <bound method MyTempfile.__del__ of <cdo.MyTempfile object at 0x2d173d0>> ignored

resulting in a residual tmp-file (ie. cdoPy6Won0D) in /tmp. Since /tmp is often constrained to small partitions it can easily
fill up completely when working with very large files.

In the case above simply using info instead of copy would solve the issue. One can also just give some arbitrary output target and delete afterwards.
Nonetheless it would probably be best to check whether output actually contains anything before trying to access it. Also in case of an exception all
tmp-files produced thus far should be deleted before exiting. Anyone else ran into this issue?

Best regards


Replies (1)

RE: Python bindings and temp files - Added by Ralf Mueller about 10 years ago

I implemented a automatic temp file removement into cdo.py because python does not do this automatically (in contrast to ruby). I'll check this.

    (1-1/1)