-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Description
Your system information
- Operating system used: Arch Linux
- PyKCS11 version: 1.5.16
- Python version: 3.12.3
- PKCS#11 library used: opensc-pkcs11
Please describe your issue in as much detail as possible:
Using the events.py example, as referenced in #167, it appears to be working but blocking KeyboardInterrupt:
Traceback (most recent call last):
File "/home/anton/test.py", line 15, in <module>
slot = pkcs11.waitForSlotEvent()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/PyKCS11/__init__.py", line 746, in waitForSlotEvent
(rv, slot) = self.lib.C_WaitForSlotEvent(flags, tmp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/PyKCS11/LowLevel.py", line 1808, in C_WaitForSlotEvent
return _LowLevel.CPKCS11Lib_C_WaitForSlotEvent(self, flags, INOUT)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
The above exception, appears to be blocked until systemctl stop pcscd.service is executed.
Steps for reproducing this issue:
import os
import PyKCS11
pkcs11 = PyKCS11.PyKCS11Lib()
if os.name == 'nt':
pkcs11.load(r"C:\Program Files\OpenSC Project\OpenSC\pkcs11\opensc-pkcs11.dll")
else:
pkcs11.load("/usr/lib/opensc-pkcs11.so")
slots = pkcs11.getSlotList()
print(slots)
while True:
try:
slot = pkcs11.waitForSlotEvent()
print(slot)
except PyKCS11.PyKCS11Error as e:
print("Error:", e)Pressing Ctrl-C will result in:
anton@hotlap ~ $ python test.py
[0]
^C^C^C^C
Until pcscd.service is restarted, then:
anton@hotlap ~ $ python test.py
[0]
^C^C^C^CTraceback (most recent call last):
File "/home/anton/test.py", line 15, in <module>
slot = pkcs11.waitForSlotEvent()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/PyKCS11/__init__.py", line 746, in waitForSlotEvent
(rv, slot) = self.lib.C_WaitForSlotEvent(flags, tmp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/PyKCS11/LowLevel.py", line 1808, in C_WaitForSlotEvent
return _LowLevel.CPKCS11Lib_C_WaitForSlotEvent(self, flags, INOUT)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
anton@hotlap ~ $