Lifecycle and resource cleanup
General reference
Closing and resource cleanup
The Python SDK does not provide a context manager for Sdk. Use try/finally for explicit cleanup:
sdk = Sdk(devices = (...))
try:
...
finally:
sdk.close()When using only the glove functionality, you can call glove.close() in finally. After closing, existing objects cannot continue to read data or use an existing
GloveDevice and subscription, otherwise ClosedHandleError is raised.
close() reclaims subscriptions that are still valid. Call subscription.unsubscribe() only when the SDK must keep running but needs to stop a certain
callback early; before the final close you do not need to unsubscribe one by one.
Recommended cleanup order:
- When running in the background, call
request_stop()to stop producing new data. - When running in the background, call
join()to wait for the thread to finish. - If vibration was set, call
clear()as required by your application. - Call
glove.close()orsdk.close()to reclaim the remaining subscriptions in a unified way.
The public command-line example ends the process directly with Ctrl+C; when a production program needs to stop actively, use background mode to perform the above order.
Sdk.close() can be called repeatedly. Glove.close() stops and closes all configured gloves and should be called once in the normal cleanup path. The destructor only serves as a fallback in exceptional cases and must not replace explicit closing.
Sdk, Glove and GloveDevice still provide connect() and disconnect(). connect() is kept only for compatibility with old code and does not open the device; disconnect() is equivalent to stop(). New code should use start() and stop() directly.