Skip to content

Commit

Permalink
getReaderNames(): handle SCARD_E_SERVICE_STOPPED on Windows
Browse files Browse the repository at this point in the history
On Windows (at least W10) when you remove the last connected reader you
get the error SCARD_E_SERVICE_STOPPED.

We can just ignore the error since a new connection will be made on next
call to getReaderNames(). See db52d27
  • Loading branch information
LudovicRousseau committed Aug 26, 2021
1 parent da43dda commit 5b43ef5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion smartcard/pcsc/PCSCCardRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def getReaderNames(self):

# get inserted readers
hresult, pcscreaders = SCardListReaders(self.hcontext, [])
if 0 != hresult and SCARD_E_NO_READERS_AVAILABLE != hresult:
if hresult in [SCARD_E_NO_READERS_AVAILABLE, SCARD_E_SERVICE_STOPPED]:
return []
if SCARD_S_SUCCESS != hresult:
raise ListReadersException(hresult)

readers = []
Expand Down

0 comments on commit 5b43ef5

Please sign in to comment.