diff --git a/platypush/backend/scard/__init__.py b/platypush/backend/scard/__init__.py index 1ac34d702..626c7790a 100644 --- a/platypush/backend/scard/__init__.py +++ b/platypush/backend/scard/__init__.py @@ -53,6 +53,8 @@ class ScardBackend(Backend): format(self.ATRs)) prev_atr = None + reader = None + while not self.should_stop(): try: cardrequest = CardRequest(timeout=None, cardType=self.cardtype) @@ -69,13 +71,13 @@ class ScardBackend(Backend): self.bus.post(SmartCardDetectedEvent(atr=atr, reader=reader)) prev_atr = atr except Exception as e: - prev_atr = None - if isinstance(e, NoCardException): - self.bus.post(SmartCardRemovedEvent()) + self.bus.post(SmartCardRemovedEvent(atr=prev_atr, reader=reader)) else: logging.exception(e) + prev_atr = None + # vim:sw=4:ts=4:et: diff --git a/platypush/message/event/scard.py b/platypush/message/event/scard.py index 9b887b72e..252d2800c 100644 --- a/platypush/message/event/scard.py +++ b/platypush/message/event/scard.py @@ -7,7 +7,7 @@ class SmartCardDetectedEvent(Event): class SmartCardRemovedEvent(Event): - def __init__(self, *args, **kwargs): + def __init__(self, atr=None, reader=None, *args, **kwargs): super().__init__(*args, **kwargs)