IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.61k stars 490 forks source link

bluepy-helper should ignore SIGINT #264

Closed mobilinkd closed 6 years ago

mobilinkd commented 6 years ago

Make the subprocess for bluepy-helper ignore SIGINT so controlling Python applications can shut down cleanly.

Now applications can do something like:

try:
    # Enable notifications
    delegate.writeCharacteristic(cccd, struct.pack('<bb', 0x01, 0x00))
    while True:
        if delegate.waitForNotifications(1.0):
            continue
except KeyboardInterrupt:
    # Disable notifications
    delegate.writeCharacteristic(cccd, struct.pack('<bb', 0x00, 0x00))
    del delegate

This addresses https://github.com/IanHarvey/bluepy/issues/191