pylink icon indicating copy to clipboard operation
pylink copied to clipboard

The temporary copy of library is not deleted when Library object is released

Open chanqueo opened this issue 2 years ago • 4 comments

I use pylink-square Python module with pytest to run tests on almost 100 devices at a time and several time a day. In some conditions I couldn't list easily here, the temporary copy of J-Link library is not deleted at the end of the tests. (probably because is is done with Library del method?) Each copy represents about 15MB on disk, this will then represent more than 1 GB after several days or weeks.

chanqueo avatar Feb 14 '23 12:02 chanqueo

Sorry about the late response here. The file should be cleaned up as a part of the __del__ (the destructor) when the class instance is garbage collected. Is it possible that your tests are exiting without allowing the Python garbage collector to run? This workaround was put in place because an early version of the library did not allow for multiple device communication from the same machine at the same time. That has since been patched, so we can probably put a version guard around the copy, but would have to be careful in how we do that; e.g. copy the library first, check the version, if it is high enough, then delete the copy and use the original.

hkpeprah avatar Feb 22 '23 15:02 hkpeprah

Hi I propose to let the user decide if he wants this copy or not in PR #172. By default, this copy is done to keep legacy behavior. User can disable it by setting use_tmpcpy to False in JLink() and/or Library() constructors.

chanqueo avatar Apr 18 '23 14:04 chanqueo

Will take a look!

hkpeprah avatar Apr 19 '23 14:04 hkpeprah

v1.1.0 should have this change in it now; sorry for the delay, and thank you for the patch!

hkpeprah avatar May 09 '23 16:05 hkpeprah