Callback Executor
The CallbackFunctionExecutor allows chaining a trigger function with a callback function.
This is useful for post-test workflows — for example, run a test, then automatically
generate a report.
Basic Usage
from je_load_density import callback_executor
def after_test():
print("Test finished, generating report...")
callback_executor.callback_function(
trigger_function_name="user_test",
callback_function=after_test,
user_detail_dict={"user": "fast_http_user"},
user_count=10,
spawn_rate=5,
test_time=5,
tasks={"get": {"request_url": "http://httpbin.org/get"}},
)
How It Works
The
trigger_function_nameis looked up in the executor’sevent_dictThe trigger function is executed with the provided
**kwargsAfter the trigger function completes, the
callback_functionis calledThe return value of the trigger function is returned
Available Trigger Functions
Trigger Name |
Function |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Passing Parameters to Callbacks
With keyword arguments (default):
def my_callback(report_name, format_type):
print(f"Generating {format_type} report: {report_name}")
callback_executor.callback_function(
trigger_function_name="user_test",
callback_function=my_callback,
callback_function_param={"report_name": "final", "format_type": "html"},
callback_param_method="kwargs",
user_detail_dict={"user": "fast_http_user"},
user_count=10,
spawn_rate=5,
test_time=5,
tasks={"get": {"request_url": "http://httpbin.org/get"}},
)
With positional arguments:
def my_callback(arg1, arg2):
print(f"Args: {arg1}, {arg2}")
callback_executor.callback_function(
trigger_function_name="user_test",
callback_function=my_callback,
callback_function_param=["value1", "value2"],
callback_param_method="args",
user_detail_dict={"user": "fast_http_user"},
user_count=10,
spawn_rate=5,
test_time=5,
tasks={"get": {"request_url": "http://httpbin.org/get"}},
)
Parameters
Parameter |
Type |
Description |
|---|---|---|
|
|
Name of function in |
|
|
Callback function to execute after the trigger |
|
|
Parameters for the callback (dict for kwargs, list for args) |
|
|
|
|
— |
Parameters passed to the trigger function |
Error Handling
CallbackExecutorExceptionis raised if:trigger_function_nameis not found inevent_dictcallback_param_methodis not"kwargs"or"args"