v3.32.4: rebuild the link on card insertion (the first attempt)
release / release (push) Waiting to run
release / release (push) Waiting to run
v3.32.2 fixed the endless re-arm, but on Windows the first attempt still failed on the old link (seen in the confirmation log: the "self._con.connect()" traceback) and only the retry recovered - a failed init, a 2-4 s delay and a traceback in the log. The monitor's insert path now marks the transport stale under _CARD_LOCK, so the first equip attempt rebuilds the PC/SC link. It also covers a link created at a cardless startup (never connected). The rebuild still happens in the equip worker, never in the pyscard monitor thread, and _ensure_transport releases the old link first. Docs: the READMEs' troubleshooting bullet. Tests: an insertion marks the transport for the rebuild. 1014 Python + 953 frontend green; simple-v462.
This commit is contained in:
@@ -35,8 +35,11 @@ class TestCardPresenceObserver(unittest.TestCase):
|
||||
self.trigger_mock = self.trigger.start()
|
||||
self.saved_auto = S._AUTO_EQUIP
|
||||
S._AUTO_EQUIP = True
|
||||
self.saved_stale = S._TRANSPORT_STALE
|
||||
S._TRANSPORT_STALE = False
|
||||
|
||||
def tearDown(self):
|
||||
S._TRANSPORT_STALE = self.saved_stale
|
||||
S._AUTO_EQUIP = self.saved_auto
|
||||
self.trigger.stop()
|
||||
self.patcher.stop()
|
||||
@@ -61,6 +64,16 @@ class TestCardPresenceObserver(unittest.TestCase):
|
||||
self.assertEqual(self.disconnects, [])
|
||||
self.trigger_mock.assert_called_once()
|
||||
|
||||
def test_insertion_marks_the_transport_for_a_rebuild(self):
|
||||
# The first equip attempt must already use a fresh link: after a swap
|
||||
# the old one cannot connect on Windows, and a cardless-startup link
|
||||
# never connected (v3.32.4).
|
||||
S._TRANSPORT_STALE = False
|
||||
self.server.card_present = False
|
||||
self.observer.update(None, ([FakeCard('Test Reader 00 00')], []))
|
||||
self.assertTrue(S._TRANSPORT_STALE)
|
||||
self.trigger_mock.assert_called_once()
|
||||
|
||||
def test_insertion_does_not_trigger_when_disabled(self):
|
||||
S._AUTO_EQUIP = False
|
||||
self.server.card_present = False
|
||||
|
||||
Reference in New Issue
Block a user