WebGUI::Test::waitForAllForks optionally taking a number of seconds to wait;
t/AssetHelper/Copy.t using this as one of its tests; this creates a test failure out of a test suite deadlock for me
This commit is contained in:
parent
6e12a8f78a
commit
ee212a16f3
2 changed files with 14 additions and 9 deletions
|
|
@ -884,21 +884,21 @@ sub cleanup {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 waitForAllForks( )
|
||||
=head2 C<< waitForAllForks( [ $wait_time ] ) >>
|
||||
|
||||
Will block until all WebGUI::Fork processes are completed.
|
||||
Optional argument C<< $wait_time >> gives a maxmimum wait time before turning in failure.
|
||||
|
||||
=cut
|
||||
|
||||
sub waitForAllForks {
|
||||
my ( $class ) = @_;
|
||||
my ( $class, $wait_time ) = @_;
|
||||
my $session = session;
|
||||
my @forkIds = $session->db->quickArray( "SELECT id FROM Fork WHERE finished != 1" );
|
||||
my $wait = 1;
|
||||
while ( $wait ) {
|
||||
$wait = 0;
|
||||
$wait = 1 if grep { !$_->isFinished } map { WebGUI::Fork->new( $session, $_ ) } @forkIds;
|
||||
return unless $wait;
|
||||
my $start_time = time;
|
||||
while ( 1 ) {
|
||||
return 1 if ! grep { !$_->isFinished } map { WebGUI::Fork->new( $session, $_ ) } @forkIds;
|
||||
return if $wait_time and $start_time + $wait_time < time;
|
||||
sleep 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue