Skip to content

Commit 98b0169

Browse files
Better handle already opened devices
1 parent a841f9f commit 98b0169

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/nitrokey/trussed/_device.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def _list_vid_pid(cls: type[T], vid: int, pid: int) -> List[T]:
282282
@classmethod
283283
def _list_pcsc_atr(cls: type[T], atr: List[int], exclusive: bool) -> List[T]:
284284
try:
285-
from smartcard.Exceptions import NoCardException
285+
from smartcard.Exceptions import CardConnectionException, NoCardException
286286
from smartcard.ExclusiveTransmitCardConnection import ExclusiveTransmitCardConnection
287287
from smartcard.System import readers
288288

@@ -299,6 +299,8 @@ def _list_pcsc_atr(cls: type[T], atr: List[int], exclusive: bool) -> List[T]:
299299
connection.connect()
300300
except NoCardException:
301301
continue
302+
except CardConnectionException:
303+
continue
302304
if atr != connection.getATR():
303305
connection.disconnect()
304306
connection.release()

0 commit comments

Comments
 (0)