WWW::Mechanize thread safety
am 17.04.2006 23:36:57 von hartctCan anyone speak to the thread-safeness of WWW::Mechanize? Is anyone
out there using it in a multi-threaded program?
Thanks,
Chris
Can anyone speak to the thread-safeness of WWW::Mechanize? Is anyone
out there using it in a multi-threaded program?
Thanks,
Chris
On Apr 17, 2006, at 4:36 PM, Christopher Hart wrote:
> Can anyone speak to the thread-safeness of WWW::Mechanize? Is anyone
> out there using it in a multi-threaded program?
Whatever you find out, please write up something that I can put into
the FAQ.
Thanks,
Andy
--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
Hi Andy,
Sent this as a response to the wrong email. So here it is with the right
subject line and sent to the list.
Andy Lester wrote:
> Whatever you find out, please write up something that I can put into
> the FAQ.
In an earlier post, I talked about using Tamper Data to find out what
Firefox is really sending to the server. Here is a way to find out what
$mech is sending.
The underlying function is from HTTP::Request: $r->as_string, where $r
is an HTTP::Request object. HTML::Form has a method $form->click which
returns the HTTP::Request object (which would normally be passed to
LWP::UserAgent). So
$f = $mech->current_form(); # or one of its cousins - gives an
# HTML::Forms object
$r = $f->click( [args] ); # returns HTTP::Request object
$t = $r->as_string(); # text of the request to compare with
# Tamper Data results.
This is not quite the same as what $mech sends, because $mech processes
the request with _modify_request, which (I believe) adds headers,
cookies and other goodies, so for this to work properly, we have
to add a step:
$f = $mech->current_form(); # or one of its cousins - gives an
# HTML::Forms object
$r = $f->click( [args] ); # returns HTTP::Request object
$r = $mech->_modify_request( $r ); # v1.12 internal routine.
# Compatibility in future releases?
$t = $r->as_string(); # text of the request to compare with
# Tamper Data results.
Given that this needs to use an internal function to get the right answer,
it would be nice if there were a method:
$mech->Pretend_to_click_and_give_me_the_message()
Cheers,
Peter
P.S. Just bought your perl debugging book today. It looks really good. :-)
Will do. For right now, I have a hunch that Crypt::SSLeay may *not*
be thread safe. I'm using WWW::Mechanize on some SSL sites in a
multi-threaded fashion and I'm getting the following error
periodically:
*** glibc detected *** /usr/bin/perl: double free or corruption
(!prev): 0x0c061650 ***
=======3D Backtrace: =========3D
/lib/libc.so.6[0x4e5424]
/lib/libc.so.6[0x4e7206]
/lib/libc.so.6(__libc_realloc+0x101)[0x4e7d30]
/lib/libcrypto.so.5[0x6c1b95]
/lib/libcrypto.so.5(CRYPTO_realloc+0x81)[0x6c21e4]
/lib/libcrypto.so.5(sk_insert+0xce)[0x70c5f0]
/lib/libcrypto.so.5(sk_push+0x2a)[0x70c6fa]
/lib/libcrypto.so.5(EVP_PBE_alg_add+0x6e)[0x71958f]
/lib/libcrypto.so.5(PKCS12_PBE_add+0x3e)[0x74ffb2]
/lib/libcrypto.so.5(OpenSSL_add_all_ciphers+0x4ed)[0x717639]
/lib/libcrypto.so.5(OPENSSL_add_all_algorithms_noconf+0x17)[ 0x71713f]
/usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/aut o/Crypt/SSLeay/=
SSLeay.so(XS_Crypt__SSLeay__CTX_new+0x33c)[0xecd990]
/usr/lib/perl5/5.8.6/i386-linux-thread-multi/CORE/libperl.so (Perl_pp_enters=
ub+0x3a5)[0x39398c]
/usr/lib/perl5/5.8.6/i386-linux-thread-multi/CORE/libperl.so (Perl_runops_de=
bug+0x141)[0x3756e1]
/usr/lib/perl5/5.8.6/i386-linux-thread-multi/CORE/libperl.so [0x322b9e]
[... snip ...]
A quick Google search resulted in a few hits with others having
similar problems. It's certainly not definitive yet, but this is
where I'm going to focus my efforts. If anyone is using Crypt::SSLeay
(through LWP or Mechanize) in a multi-threaded fashion successfully,
I'd be interested in hearing from you. I'll let you know what I find.
If anyone has any debugging tips for this type of error, I'd be happy
to try them out! :-)
Chris
On 4/17/06, Andy Lester
>
> On Apr 17, 2006, at 4:36 PM, Christopher Hart wrote:
>
> > Can anyone speak to the thread-safeness of WWW::Mechanize? Is anyone
> > out there using it in a multi-threaded program?
>
> Whatever you find out, please write up something that I can put into
> the FAQ.
>
> Thanks,
> Andy
>
> --
> Andy Lester =3D> andy@petdance.com =3D> www.petdance.com =3D> AIM:petdanc=
e
>
>
>
>