convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

try additional file removal strategy #1445

Closed bqpd closed 4 years ago

galbramc commented 5 years ago

test this please

galbramc commented 5 years ago

I still see temporary files lingering. I saw a number of temporary directories created and deleted, but not all got deleted. The directories that remain have gpkit_mosek and gpkit_mosek.sol files in them.

galbramc commented 5 years ago

Maybe you need some while loop to check if the file still lingers.

bqpd commented 5 years ago

huh, they should all be getting deleted: either by os.remove or by shutil.rmtree! Even weirder that some are and some are not deleted.

One (kinda silly) alternative could be to reuse the same temporary filename for each session of gpkit, which should work but also creates an entirely unnecessary potential race condition.

On Thu, Oct 17, 2019 at 12:55 PM Marshall Galbraith < notifications@github.com> wrote:

I still see temporary files lingering. I saw a number of temporary directories created and deleted, but not all got deleted. The directories that remain have gpkit_mosek and gpkit_mosek.sol files in them.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/pull/1445?email_source=notifications&email_token=AALKAGCEYBJSEB3U6MC4NO3QPCKGHA5CNFSM4JB3IYJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBQZNXQ#issuecomment-543266526, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGGKEKVBGJ5LJ5OC64TQPCKGHANCNFSM4JB3IYJQ .

bqpd commented 5 years ago

There is a while loop in the rmtree function! If all remaining directories also have files leftover, that implies os.remove isn't doing anything, so this PR isn' necessary.

On Thu, Oct 17, 2019 at 12:59 PM Marshall Galbraith < notifications@github.com> wrote:

Maybe you need some while loop to check if the file still lingers.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/pull/1445?email_source=notifications&email_token=AALKAGEXQUKZD6SCDBGEX43QPCKTBA5CNFSM4JB3IYJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBQZYIQ#issuecomment-543267874, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGHNPASWT4POAA2NBS3QPCKTBANCNFSM4JB3IYJQ .

galbramc commented 5 years ago

Welcome to the world of windoze. I'm guessing Windoze is locking the file claiming it is still in use when you are trying to remove it. Humor me and put a while exists in front of each remove command.

bqpd commented 5 years ago

done! added while loop

galbramc commented 5 years ago

test this please

galbramc commented 5 years ago

You missed the '.path.'. Should be:

os.path.isfile(filename)
bqpd commented 5 years ago

derp

On Thu, Oct 17, 2019 at 3:42 PM Marshall Galbraith notifications@github.com wrote:

You missed the '.path.'. Should be:

os.path.isfile(filename)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/pull/1445?email_source=notifications&email_token=AALKAGHKVF6MAYD5NBFVXRLQPC5XLA5CNFSM4JB3IYJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBRJCWI#issuecomment-543330649, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGCAQFU232JBUFFWW4LQPC5XLANCNFSM4JB3IYJQ .

galbramc commented 5 years ago

Nope... try this:

try:
    shutil.rmtree(path)
except OSError as e:
    # Reraise unless ENOENT: No such file or directory
    # (ok if directory has already been deleted)
    if e.errno != errno.ENOENT:
        raise
bqpd commented 5 years ago

Heh, wrapped it around my existing recursion; how's that?

galbramc commented 5 years ago

Geez! I don't know why some still linger... For all these incarnations there are fewer left behind, there are still ~5-10 that don't get deleted.

galbramc commented 5 years ago

Oh wait. Wrong PR building.

galbramc commented 5 years ago

Try removing the extra arguments to shutil.rmtree.

bqpd commented 5 years ago

done! :| thanks so much for like...watching the temporary files directory

On Thu, Oct 17, 2019 at 4:33 PM Marshall Galbraith notifications@github.com wrote:

Try removing the extra arguments to shutil.rmtree.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/pull/1445?email_source=notifications&email_token=AALKAGFLIPFFFMXZXGWTEJ3QPDD2VA5CNFSM4JB3IYJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBRN3SQ#issuecomment-543350218, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGENEKXWTDMAA5XC2D3QPDD2VANCNFSM4JB3IYJQ .

galbramc commented 5 years ago

I don't understand this... There are still files lingering, but it is better than what it was without any of these changes. Maybe the while should be on the directory instead of the file inside?

bqpd commented 5 years ago

heh. giving that a try...

On Thu, Oct 17, 2019 at 5:33 PM Marshall Galbraith notifications@github.com wrote:

I don't understand this... There are still files lingering, but it is better than what it was without any of these changes. Maybe the while should be on the directory instead of the file inside?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/pull/1445?email_source=notifications&email_token=AALKAGHKKRHQAKCJRHTA36DQPDKXNA5CNFSM4JB3IYJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBRS4MQ#issuecomment-543370802, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGCN7U5RYGHYVFMYEBTQPDKXNANCNFSM4JB3IYJQ .