diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2022-06-02 12:20:17 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-06-02 12:20:17 +0300 |
commit | f4456a4d3c9767da76041bfa48e623cf6afa59ce (patch) | |
tree | 6d489e1244cd6024ac3f9e53d850548e73e51824 /source/blender/python/intern/bpy_app_handlers.c | |
parent | 40ecf9d606358d773bfe977e6bc85580e5818cc6 (diff) |
Expose background job info to Python
Add `bpy.app.is_job_running(job_type)` as high-level indicator. Job
types currently exposed are `WM_JOB_TYPE_RENDER`,
`WM_JOB_TYPE_RENDER_PREVIEW`, and `WM_JOB_TYPE_OBJECT_BAKE`, as strings
with the `WM_JOB_TYPE_` prefix removed. The functions can be polled by
Python code to determine whether such background work is still ongoing
or not.
Furthermore, new app handles are added for
`object_bake_{pre,complete,canceled}`, which are called respectively
before an object baking job starts, completes sucessfully, and stops due
to a cancellation.
Motivation: There are various cases where Python can trigger the
execution of a background job, without getting notification that that
background job is done. As a result, it's hard to do things like
cleanups, or auto-quitting Blender after the work is done.
The approach in this commit can easily be extended with other job types,
when the need arises. The rendering of asset previews is one that's
likely to be added sooner than later, as there have already been
requests about this.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D14587
Diffstat (limited to 'source/blender/python/intern/bpy_app_handlers.c')
-rw-r--r-- | source/blender/python/intern/bpy_app_handlers.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index bf427d9639a..40f4b8af1cc 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -67,6 +67,10 @@ static PyStructSequence_Field app_cb_info_fields[] = { {"annotation_pre", "on drawing an annotation (before)"}, {"annotation_post", "on drawing an annotation (after)"}, + {"object_bake_pre", "before starting a bake job"}, + {"object_bake_complete", "on completing a bake job; will be called in the main thread"}, + {"object_bake_cancel", "on canceling a bake job; will be called in the main thread"}, + /* sets the permanent tag */ #define APP_CB_OTHER_FIELDS 1 {"persistent", |