Skip to content

Commit

Permalink
fix #74: plugout the last device will raise an smartcard.Exceptions.L…
Browse files Browse the repository at this point in the history
…istReadersException error,-2146435043/8010001D
  • Loading branch information
gongleilei committed May 16, 2020
1 parent 203487d commit 2e9cb09
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion smartcard/CardMonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def run(self):
# To solve this, we set the stop event and pass the
# exception to let the thread finish gracefully.
if exc.hresult == SCARD_E_NO_SERVICE:
self.stopEvent.set()
pass
# self.stopEvent.set()

# stop the thread by signaling stopEvent
def stop(self):
Expand Down
1 change: 1 addition & 0 deletions smartcard/pcsc/PCSCCardRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self, newcardonly=False, readers=None,
def getReaderNames(self):
"""Returns the list or PCSC readers on which to wait for cards."""

self.hcontext = PCSCContext().getContext()
# get inserted readers
hresult, pcscreaders = SCardListReaders(self.hcontext, [])
if 0 != hresult and SCARD_E_NO_READERS_AVAILABLE != hresult:
Expand Down
3 changes: 1 addition & 2 deletions smartcard/pcsc/PCSCContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def releaseContext(self):
def __init__(self):
PCSCContext.mutex.acquire()
try:
if not PCSCContext.instance:
self.renewContext()
self.renewContext()
finally:
PCSCContext.mutex.release()

Expand Down

0 comments on commit 2e9cb09

Please sign in to comment.