aiplan4eu / unified-planning

The AIPlan4EU Unified Planning Library
Apache License 2.0
193 stars 41 forks source link

Cleanup temp directory after generating plans. #537

Closed MFaisalZaki closed 10 months ago

MFaisalZaki commented 11 months ago

Removing the temp directory after generating the plans will be better. Note that generating lots of plans without cleaning such a directory will take more inodes, which will impact the filesystem and would easily lead to consuming all inodes, preventing the system from creating new files.

The change is simple and can be done at this line:

tmpdir = tempfile.TemporaryDirectory()
# Do the planning stuff

# Invoke cleanup after solving the planning task.
tmpdir.cleanup()

Thanks @speckdavid for highlighting this.

alvalentini commented 11 months ago

We use the tempfile with the with statement. It automatically deletes the directory at the end.

See here and here.

MFaisalZaki commented 10 months ago

This makes sense. Thanks a lot for highlighting this.