darktable-org / darktable-org/lua-scripts
help wanted: strange / unknown behaviour of gui.create_job
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lua
- Star
- 219
- Fork
- 142
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I'm currently writing (or, trying to write 🙄) a lua script that will generate the preview cache for selected images (without leaving dt to start the external program...). Basically, it seems to work but I see two strange things that I don't understand right now.
First, the essential parts of my script:
local function stop_job( job )
job.valid = false
end
local function create_previews()
job = dt.gui.create_job( "generating previews", true, stop_job )
local images = dt.gui.action_images
for i,image in pairs(images) do
if job.valid then
image:generate_cache( true, 0, 8 )
job.percent = i / #images
dt.control.sleep( 1 ) -- without this, the job cannot be aborted
else
break
end
end
if job.valid then -- without this, dt crashes with an exception in dt_pthread_mutex_destroy() after aborting the job
job.valid = false
end
end
the create_previews function will be called from a registered action.
My two questions:
-
Without the sleep() I cannot stop the running job. After starting the job, the progress bar is shown and when I hit the 'X' nothing happens until the for loop processed all images. Then the stop_job() is called. With the sleep the stop_job is called after processing the current image and the job terminates as desired.
-
When I set the job.valid to false after the loop it only works as long as the job is not terminated via the stop_job function. As this already sets the job to invalid I guess it is already destroyed and in the second job.valid=false dt crashes with an exception in dt_pthread_mutex_destroy.
Both phenomena are completely understandable, but: I see a lot of scripts that execute job.valid=false twice (when aborted) and seem to rely on stopping without a call to sleep(). Hmmm. What I'm missing here?
I hope you can clarify this,
thanks a lot!
Christian
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với action đã đăng ký được hiển thị và tái hiện việc hủy dt.gui.create_job cả khi có và khi không có dt.control.sleep. Theo dõi vòng đời của job.valid xung quanh stop_job và phép gán cuối cùng, sử dụng phần triển khai Lua API hoặc các script hiện có được issue đề cập. Được xem là hoàn tất khi hành vi hủy và cách sử dụng an toàn vòng đời của job đã được làm rõ hoặc sửa lại mà không xảy ra crash đã được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- api
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100