http://qs321.pair.com?node_id=11115294


in reply to Re: Break out from download
in thread Break out from download

Hi Ken

I do not quite get it: invoking die() as for killing my script (main program). I can't find any object method called die in LWP.

Replies are listed 'Best First'.
Re^3: Break out from download
by jcb (Parson) on Apr 10, 2020 at 01:27 UTC

    LWP invokes the callback inside an eval; using die will be caught and translated into an "X-Died" header in the response object.

    You will need to arrange for the "Cancel" button to set a flag that the callback then checks. Having the Tk callback handler directly die will abort the run through the event loop and may or may not cause problems. Tk is a very complex XS module, so it would be best to avoid throwing an exception "around the event loop" directly.

Re^3: Break out from download
by Fletch (Bishop) on Apr 09, 2020 at 23:10 UTC

    The die can be caught with an eval and will not necessarily always cause perl to exit.

    (But POSIX has _exit if you ever did need to stop a process immediately</extrememly-tangentially-related-aside>).

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re^3: Break out from download
by Anonymous Monk on Apr 09, 2020 at 20:29 UTC
    invoking die() as for killing my script (main program)

    does it, tho? maybe try first, worry later?