evcxr / evcxr

Other
5.5k stars 217 forks source link

The temperary files generated by evcxr don't delete automatically. #269

Open baiguoname opened 1 year ago

baiguoname commented 1 year ago

Every time I start a new session of evcxr, it generated a temp file in the directory "C:/User/User/AppData/Temp/", almost 500M. Can it be deleted automatically after I restart the session?

baiguoname commented 1 year ago

For example, in my computer: image

davidlattimore commented 1 year ago

Thanks for the report @baiguoname. How are you exiting from evcxr? I just tried and at least for me, if I exit by pressing ctrl-d, it cleans up. It looks like the :quit command however doesn't clean up, so that should probably be fixed.

baiguoname commented 1 year ago

Thanks for your attention to this. I use evcxr in vscode jupyter extention, and I exit the jupyter with restart the jupyter kernel or just close the entire vscode app. I test the same process on jupyterlab, the problem is still there.

davidlattimore commented 1 year ago

I just tried in Jupyter Notebook (on Linux) and both Kernel->Restart and Kernel->Shutdown resulted in the temporary directory being cleaned up.

If in Jupyter Lab, I run :last_compile_dir to see where the temporary directory is, then close the notebook, I can see that the directory still exists. However, it looks like this is because Jupyter Lab hasn't shut down the kernel. If I go to Kernel sessions (see screenshot below), I can see that the kernel is still running. If I tell it to shut down, then the temporary directory gets deleted.

image

As far as I can tell, the directory is getting cleaned up when Jupyter asks the kernel to shut down. At least it is on Linux.... hmm, I just tried it on Windows and some stuff did indeed get left behind. I'm guessing that probably the subprocess is still running and is holding a lock on the DLLs, preventing them from being deleted. Probably we just need to make sure that we terminate the subprocess when we're shutting down before we clean up the temporary directory.

davidlattimore commented 1 year ago

I didn't actually mean to close this, since I should probably do something about the :quit command.