I'm still having occasional script interrupted errors even with all the thread safe coding I've been doing. I added some flags so I could tell where the script was interrupting. Of course, it's not in the place I thought it was.
Since installing the flags, the script interrupted on 2 occasions AFTER capt_seq_hook_set_nr() is called, and BEFORE raw_save_file() is called. This time period is around 250 msec plus the shutter open time. During this time period, core_spytask() and the script are both active in different threads.
The flags also show that the script error happens when the script is waiting for the shot to be ready. The last flagged routine was get_shot_ready(). However, during the loop, I also am calling other functions, including:
is_pressed("display")
is_pressed("menu")
is_pressed("set")
sleep(10)
get_shot_ready()
I've added a flag in each of these routines to try to determine where the script error happens, but I haven't been able to trigger the error with the new flags yet. I think core_spytask() is calling is_pressed() too, so it might be possible that is_pressed() is being called from different threads at the same time.
Anyway, I'm getting a little closer to an answer, I hope. If anyone has an idea how a multi-threading problem could cause a script interrupted error at this point in the shooting cycle, please let me know. The error message is "set" the last 3 times it happened. Here's the end of the last log file:
1524 3519 3470 30 50 411 88 -3 1/5.78
1525 3520 3450 40 30 411 89 -2 1/5.69
1526 3521 3460 40 30 411 89 -2 1/5.61
set
*** TERMINATED ***
This is what I'm printing in the log: (G1X)
shot#, exposure#, pre-shot delay time (4 sec interval), shot meter time, script time, sv96, bv correction, ev96 change, shutter time
=========
The exposure time, tv96, isn't as accurate as sv96. So when you set tv96 based on get_shot_meter(), it sometimes over-corrects and causes small oscillations in brightness in the time lapse video. These are only visible as it gets dark. Anyway, I modified get_shot_meter() to under_correct by 1 ev96, which appears to have eliminated or greatly reduced the oscillations.
My test time lapses lately have been deadly dull, since it's just watching fog get darker or lighter. But at least they change exposure smoothly. Here's the one from this morning (no script interrupt, unfortunately):
http://www.youtube.com/watch?v=fM0TV7bm4tA#ws