feat(protocol): add cancellable session interruption

This commit is contained in:
Jason Morcos committed 2026-08-14 14:37:30 -07:00
1 parent a44930f9df
commit 3f0e437880
5 files changed
+455 -17

No files matched your search

+16
View File
@@ -57,6 +57,22 @@ retransmissions within that same deadline:
sess.connect(timeout=4.0)
```
Connection attempts can also use a one-way cancellation signal. The signal is
backed by a socketpair, so setting it wakes the network wait immediately while
OpenSSL retains control of DTLS retransmission timing:
```python
from smartthings_local.protocol.dtls_session import ConnectCancellation
cancel_connect = ConnectCancellation()
# Another thread may call cancel_connect.set().
sess.connect(timeout=8.0, cancel=cancel_connect)
```
Setting the signal stops subscribed connection attempts and closes their
temporary UDP sockets. It does not alter an already established session or add
new session lifecycle methods. Interrupted attempts raise `SessionClosedError`.
If the cert/key are minted at runtime and never written to disk (e.g. inside
an HA config flow), create the provider from memory instead: