Skip Menu |
 

This queue is for tickets about the WWW-Mechanize-Chrome CPAN distribution.

Report information
The Basics
Id: 130866
Status: open
Priority: 0/
Queue: WWW-Mechanize-Chrome

People
Owner: Nobody in particular
Requestors: Chris.Denley [...] experian.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Date: Thu, 31 Oct 2019 15:38:31 +0000
Subject: Chrome data directory locked
To: "bug-WWW-Mechanize-Chrome [...] rt.cpan.org" <bug-WWW-Mechanize-Chrome [...] rt.cpan.org>
From: "Denley, Chris" <Chris.Denley [...] experian.com>
I had an issue with WWW::Mechanize::Chrome not working if Chrome was already started. That seems to be resolved with using a different data directory than the already-running instance. I decided to use tempdir as demonstrated in the documentation for the data_directory option to ensure I always use a clean and unique data directory which is always deleted when the script finishes. However, there doesn't seem to be a good way for ensuring the Chrome process has completed and the temporary directory can be safely cleaned except for waiting a fixed period of time after the WWW::Mechanize::Chrome object is destroyed before allowing the tempdir variable to be destroyed, or waiting until CrashpadMetrics-active.pma can be deleted without error as in my workaround. Perhaps there should be a "close" method available that will return once all Chrome processes have completed and the data_directory can be safely deleted. Chrome 78 on Windows 10 Strawberry Perl 5.24.4 WWW::Mechanize::Chrome 0.37 Without my workaround, this is the error I get when the temp directory cleanup fails: cannot unlink file for C:\Users\do382cd\AppData\Local\Temp\1\HjecI5Ixs5\CrashpadMetrics-active.pma: Permission denied at C:/strawberry/perl/lib/File/Temp.pm line 784. cannot remove directory for C:/Users/do382cd/AppData/Local/Temp/1/HjecI5Ixs5: Directory not empty at C:/strawberry/perl/lib/File/Temp.pm line 784. Test script: use strict; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; use File::Temp 'tempdir'; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $tmpdir = tempdir(CLEANUP => 1 ); { # limit scope of $mech so it is destroyed before $tmpdir my $mech = WWW::Mechanize::Chrome->new(data_directory => $tmpdir); $mech->get("https://metacpan.org/pod/WWW::Mechanize::Chrome"); } exit(0); # comment this out for my workaround # wait for file to be released so $tmpdir will be cleaned my $path = "$tmpdir/CrashpadMetrics-active.pma"; for(1..10) { last unless(-e $path); unlink($path) and last; sleep(1); }

Message body is not shown because it is too large.

Subject: Re: [rt.cpan.org #130866] Chrome data directory locked
Date: Sat, 2 Nov 2019 10:42:32 +0100
To: bug-WWW-Mechanize-Chrome [...] rt.cpan.org
From: Max Maischein <corion [...] corion.net>
Download (untitled) / with headers
text/plain 2.9k
Hello Chris, I have just released version 0.38 to CPAN, which now has the "wait_file" option. You should be able to use it as: my $mech = WWW::Mechanize::Chrome->new( data_directory => $tempdir, wait_file => "$tempdir/CrashpadMetrics-active.pma", ); It mostly implements what your code did, waiting for the file to disappear or become deletable when the objects gets destroyed. Please let me know if that helps. Thank you for reporting this bug, -max On 31.10.19 17:06, Denley, Chris via RT wrote: Show quoted text
> Thu Oct 31 12:06:22 2019: Request 130866 was acted upon. > Transaction: Ticket created by Chris.Denley@experian.com > Queue: WWW-Mechanize-Chrome > Subject: Chrome data directory locked > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: Chris.Denley@experian.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=130866 > > > > I had an issue with WWW::Mechanize::Chrome not working if Chrome was already started. That seems to be resolved with using a different data directory than the already-running instance. I decided to use tempdir as demonstrated in the documentation for the data_directory option to ensure I always use a clean and unique data directory which is always deleted when the script finishes. However, there doesn't seem to be a good way for ensuring the Chrome process has completed and the temporary directory can be safely cleaned except for waiting a fixed period of time after the WWW::Mechanize::Chrome object is destroyed before allowing the tempdir variable to be destroyed, or waiting until CrashpadMetrics-active.pma can be deleted without error as in my workaround. Perhaps there should be a "close" method available that will return once all Chrome processes have completed and the data_directory can be safely deleted. > > Chrome 78 on Windows 10 > Strawberry Perl 5.24.4 > WWW::Mechanize::Chrome 0.37 > > Without my workaround, this is the error I get when the temp directory cleanup fails: > cannot unlink file for C:\Users\do382cd\AppData\Local\Temp\1\HjecI5Ixs5\CrashpadMetrics-active.pma: Permission denied at C:/strawberry/perl/lib/File/Temp.pm line 784. > cannot remove directory for C:/Users/do382cd/AppData/Local/Temp/1/HjecI5Ixs5: Directory not empty at C:/strawberry/perl/lib/File/Temp.pm line 784. > > Test script: > > use strict; > use Log::Log4perl qw(:easy); > use WWW::Mechanize::Chrome; > use File::Temp 'tempdir'; > > Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR > my $tmpdir = tempdir(CLEANUP => 1 ); > { > # limit scope of $mech so it is destroyed before $tmpdir > my $mech = WWW::Mechanize::Chrome->new(data_directory => $tmpdir); > $mech->get("https://metacpan.org/pod/WWW::Mechanize::Chrome"); > } > exit(0); # comment this out for my workaround > > # wait for file to be released so $tmpdir will be cleaned > my $path = "$tmpdir/CrashpadMetrics-active.pma"; > for(1..10) { > last unless(-e $path); > unlink($path) and last; > sleep(1); > } > >
Date: Thu, 14 Nov 2019 20:37:57 +0000
Subject: RE: [rt.cpan.org #130866] AutoReply: Chrome data directory locked
To: "bug-WWW-Mechanize-Chrome [...] rt.cpan.org" <bug-WWW-Mechanize-Chrome [...] rt.cpan.org>
From: "Denley, Chris" <Chris.Denley [...] experian.com>
Download (untitled) / with headers
text/plain 3.8k
Thank you for the support. The wait_file change does not seem to be working though. Using WWW::Mechanize::Chrome 0.39. It still fails to delete CrashpadMetrics-active.pma when $tmpdir is destroyed. I could just keep my workaround in place though. use strict; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; use File::Temp 'tempdir'; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $tmpdir = tempdir(CLEANUP => 1 ); { # limit scope of $mech so it is destroyed before $tmpdir my $mech = WWW::Mechanize::Chrome->new(data_directory => $tmpdir, wait_file => "$tmpdir/CrashpadMetrics-active.pma"); $mech->get("https://metacpan.org/pod/WWW::Mechanize::Chrome"); $mech->close; $mech->DESTROY; } exit(0); Show quoted text
-----Original Message----- From: Bugs in WWW-Mechanize-Chrome via RT <bug-WWW-Mechanize-Chrome@rt.cpan.org> Sent: Thursday, October 31, 2019 11:06 AM To: Denley, Chris <Chris.Denley@experian.com> Subject: [rt.cpan.org #130866] AutoReply: Chrome data directory locked Greetings, This message has been automatically generated in response to the creation of a trouble ticket regarding: "Chrome data directory locked", a summary of which appears below. There is no need to reply to this message right now. Your ticket has been assigned an ID of [rt.cpan.org #130866]. Your ticket is accessible on the web at: https://rt.cpan.org/Ticket/Display.html?id=130866 Please include the string: [rt.cpan.org #130866] in the subject line of all future correspondence about this issue. To do so, you may reply to this message. Thank you, bug-WWW-Mechanize-Chrome@rt.cpan.org ------------------------------------------------------------------------- I had an issue with WWW::Mechanize::Chrome not working if Chrome was already started. That seems to be resolved with using a different data directory than the already-running instance. I decided to use tempdir as demonstrated in the documentation for the data_directory option to ensure I always use a clean and unique data directory which is always deleted when the script finishes. However, there doesn't seem to be a good way for ensuring the Chrome process has completed and the temporary directory can be safely cleaned except for waiting a fixed period of time after the WWW::Mechanize::Chrome object is destroyed before allowing the tempdir variable to be destroyed, or waiting until CrashpadMetrics-active.pma can be deleted without error as in my workaround. Perhaps there should be a "close" method available that will return once all Chrome processes have completed and the data_directory can be safely deleted. Chrome 78 on Windows 10 Strawberry Perl 5.24.4 WWW::Mechanize::Chrome 0.37 Without my workaround, this is the error I get when the temp directory cleanup fails: cannot unlink file for C:\Users\do382cd\AppData\Local\Temp\1\HjecI5Ixs5\CrashpadMetrics-active.pma: Permission denied at C:/strawberry/perl/lib/File/Temp.pm line 784. cannot remove directory for C:/Users/do382cd/AppData/Local/Temp/1/HjecI5Ixs5: Directory not empty at C:/strawberry/perl/lib/File/Temp.pm line 784. Test script: use strict; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; use File::Temp 'tempdir'; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $tmpdir = tempdir(CLEANUP => 1 ); { # limit scope of $mech so it is destroyed before $tmpdir my $mech = WWW::Mechanize::Chrome->new(data_directory => $tmpdir); $mech->get("https://metacpan.org/pod/WWW::Mechanize::Chrome"); } exit(0); # comment this out for my workaround # wait for file to be released so $tmpdir will be cleaned my $path = "$tmpdir/CrashpadMetrics-active.pma"; for(1..10) { last unless(-e $path); unlink($path) and last; sleep(1); }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.