Hi everyone,
I’m trying to get the state of a background task on the front end. The task ID is stored in the database and not directly available on the front end as the data is displayed on different pages than where the task was originally executed.
According to the documentation (doc1, doc2), I should be able to use:
anvil.server.get_background_task(task_id)
Or
anvil.server.list_background_tasks()
However, when I try to use get_background_task()
, I get the following error: AttributeError: module 'anvil.server' has no attribute 'get_background_task'
To investigate further, I printed the available attributes of anvil.server
using:
print(dir(anvil.server))
And the result does not include get_background_task
or list_background_tasks
. Instead, I see the following available attributes:
[‘AnvilSessionExpiredException’, ‘AnvilWrappedError’, ‘AppOfflineError’, ‘BackgroundTaskError’, ‘BackgroundTaskKilled’, ‘BackgroundTaskNotFound’, ‘Capability’, ‘ExecutionTerminatedError’, ‘InternalError’, ‘InvalidResponseError’, ‘LazyMedia’, ‘NoServerFunctionError’, ‘PermissionDenied’, ‘QuotaExceededError’, ‘RuntimeUnavailableError’, ‘Serializable’, ‘SerializationError’, ‘SerializationInfo’, ‘ServiceNotAdded’, ‘SessionExpiredError’, ‘TimeoutError’, ‘UplinkDisconnectedError’, ‘FailError’, '_ getattr ', ’ name __’, ‘_call_http’, ‘_invalidation_callbacks’, ‘_n_invalidations’, ‘_on_invalidate_client_objects’, ‘_register_exception_type’, ‘add_event_handler’, ‘app_origin’, ‘call’, ‘call_s’, ‘context’, ‘event_handler’, ‘get_api_origin’, ‘get_app_origin’, ‘invalidate_client_objects’, ‘is_app_online’, ‘launch_background_task’, ‘loading_indicator’, ‘no_loading_indicator’, ‘portable_class’, ‘remove_event_handler’, ‘reset_session’, ‘serializable_type’, ‘server_method’, ‘unwrap_capability’]
–
My Questions:
- Has anyone successfully retrieved a background task by task ID?
- Could this be a version issue or a documentation mismatch?
- Is there an alternative approach to track the status of a background task when the task ID is stored in the database and needs to be accessed on another page?
Any insights would be appreciated. Thanks!