Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Break out from download

by kcott (Archbishop)
on Apr 09, 2020 at 19:49 UTC ( [id://11115293]=note: print w/replies, xml ) Need Help??


in reply to Break out from download

G'day IB2017,

"Is there an easy way to break out of the download"

Take a look at the last paragraph of "LWP::UserAgent: get" which has:

"The callback can abort the request by invoking die()."

— Ken

Replies are listed 'Best First'.
Re^2: Break out from download
by IB2017 (Pilgrim) on Apr 09, 2020 at 20:05 UTC

    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.

      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.

      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.

      invoking die() as for killing my script (main program)

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11115293]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found