mpeppler has asked for the wisdom of the Perl Monks concerning the following question:
The framework supports this interrupt functionality, but it must know what request it needs to interrupt, meaning that the $SIG{INT}/$SIG{TERM} subroutine needs to know which DBI statement handle is active at the time, and act accordingly.
My initial thought was to do something like this:
Initial testing appear to show that this works, but I'm worried that by using a closure like this $req will never get destroyed due to dangling references. I haven't really used closures before, so my experience in that area is rather limited.# This is $sth->execute sub execute { my $sth = shift; .... my $req = BigHairyDatabaseInteraction->new(...); local $SIG{INT} = sub { $req->handleInterrupt }; $req->execute; # When $req->excute comes back the entire query # has been processed, and all the rows are in $req. ... }
Does the above technique seem reasonable, or would you suggest other techniques to achieve the same result?
Thanks!
Michael
|
|---|