[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pcall() in chdk lua
- From: Patrick Donnelly <batrick@...>
- Date: Sat, 8 Aug 2009 16:14:42 -0700
On Sat, Aug 8, 2009 at 12:49 PM, Matt Kime<mattkime@gmail.com> wrote:
> I'm using lua on chdk which runs on a Canon Powershot a650IS, a point
> and shoot camera. I'm trying to use pcall() in order to trap errors
> I'm unable to eliminate in my scripts. more specifically, there are a
> couple of chdk native functions (press("half_shoot"),
> release("half_shoot"))which very occasionally fail. (1% to 0.1% of the
> time) unfortunately calling these functions through pcall results in
> the following error message -
>
> attempt to yield across metamethod / c-call boundary
>
> any advice on how to resolve this?
>
> I realize that chdk lua specific issues may be at fault but any ideas
> or suggestions on how to fix or work around this are greatly
> appreciated.
This sounds like a problem Nmap had itself. We yield the current
script whenever it performs a socket operation. This unfortunately
makes it very difficult for the script to catch errors because you
can't yield across a pcall. There is an alternative to pcall: one can
use a coroutine to run code protected. The issue is propagating a
yield back to the system as it was intended. I recently added a patch
to Nmap that hooks coroutine.resume and coroutine.wrap to propagate
Nmap initiated yields back to Nmap through all the script's
coroutines. When Nmap again resumes the script, the resume goes back
up the chain of coroutines. If your platform is willing to make a
similar patch, its users can use coroutine.resume to make protected
calls while keeping the system yields working properly.
--
-Patrick Donnelly
"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."
- Benjamin Franklin