Python
The Hackle Python SDK supports Python 3 and above.
If you are using a WSGI environment, be sure to check the WSGI Configuration guide.
Add Dependency
pip install hackle-sdkSDK Initialization
hackle_client is a global variable and must be created only once.
hackle_client manages state internally to evaluate results immediately from threads without I/O.
This uses additional resources for that purpose.
Do not create a new instance for every request; instead, use the already-created instance.
Since hackle_client is built as a singleton object, using hackle.Client() in other functions will not recreate it.
hackle_client is the class that provides methods for using SDK features.
To use the SDK, you need to initialize hackle_client.
Instantiation
Instantiate hackle_client by passing the SDK Key.
hackle_client periodically synchronizes with the Hackle server as a background task to obtain the necessary information.
You can find the SDK Key in SDK Integration Info located inside the Hackle Service Dashboard.
Shutdown
When the application shuts down, you must shut down hackle_client using the hackle_client.close() method.
This releases resources in use and sends any remaining events.
If the application shuts down without calling hackle_client.close(), events may be lost.
Using Flask or Django?
You can use @atexit.register to automatically shut down hackle_client when the application exits.
Last updated