Closed stamfest closed 4 years ago
Exact. I will have a look.
Note that .releaseContext()
is called internally https://github.com/LudovicRousseau/pyscard/blob/master/smartcard/pcsc/PCSCContext.py#L68
I don't find any memory leak.
I also tried again with Python 3.8 and the latest build (from today) and I can't reproduce the problem. I don't know why the code provided in the previous Windows package version was incorrect. Very strange. https://ci.appveyor.com/project/LudovicRousseau/pyscard/build/job/mog60l88k1o6mwlq/artifacts
I now have the same handle.
Just tried this again using Python 3.8.2 and pyscard-1.9.9 on a win10 machine. Two different handles. I just wonder what's going on here, since the one use of the singleton pattern I see here is to provide one context handle. And I just cannot see the code path that should lead to two invocations of SCardEstablishContext and similarly I cannot see the code path to the .releaseContext method in my super trivial 3-liner.
Where did you get pyscard? rebuild from source code?
I downloaded pyscard-1.9.9.win-amd64-py3.8.exe on June 14th from https://ci.appveyor.com/project/LudovicRousseau/pyscard/
Download and install it again.
The package 1.9.9 I used also had not the correct code in https://github.com/LudovicRousseau/pyscard/blob/master/smartcard/pcsc/PCSCContext.py compared to the official repository. The code looks correct now. I have no idea how the generated package could have a wrong code. Maybe appveyor can't be trusted?
Damn. You are right. The new version does not show this phenomenon. This smells extremely fishy.
Just to add why I went to appveyor: Other parts of the project require python 3.7 but SF only carries windows packages for 3.6...
I added the files for Python 3.7 and 3.8 at https://sourceforge.net/projects/pyscard/files/pyscard/pyscard%201.9.9/
You can also get the binaries from PyPI at https://pypi.org/project/pyscard/#files
I stumbled across the following phenomenon. When running this minimal program:
I see differences between Linux and Windows. On Linux the two numbers output are equal. On windows they aren't. When looking at the code, I see that the returned context handle wrapper object is created as a singleton and the handle is created using a call to SCardEstablishContext.. It now makes me nervous that there is a different handle returned on every call to getContext(), especially since I cannot find a call to SCardReleaseContext, indicating that there might be some resource leak because of this. This likely would have a negative effect on long running programs. My question is: What is going on here? And: Is this a problem?