[libweasel-perl] 16/24: * Add poll_delay and retry_timeout parameters

Robert James Clay jame at rocasa.us
Tue Aug 15 19:16:08 UTC 2017


This is an automated email from the git hooks/post-receive script.

jame-guest pushed a commit to tag v0.02
in repository libweasel-perl.

commit c33804f734a47373e250a3621532be48f5f57429
Author: Erik Huelsmann <ehuels at gmail.com>
Date:   Mon Jun 20 09:58:52 2016 +0200

    * Add poll_delay and retry_timeout parameters
---
 lib/Weasel/DriverRole.pm |  8 +++++++-
 lib/Weasel/Session.pm    | 40 +++++++++++++++++++++++++++++++++++-----
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/lib/Weasel/DriverRole.pm b/lib/Weasel/DriverRole.pm
index 24fb003..496b0c9 100644
--- a/lib/Weasel/DriverRole.pm
+++ b/lib/Weasel/DriverRole.pm
@@ -104,7 +104,13 @@ sub is_displayed {
     croak "Abstract interface method 'is_displayed' called";
 }
 
-=item wait_for( $callback )
+=item wait_for( $callback, retry_timeout => $num, poll_delay => $num )
+
+The driver may interpret the 'poll_delay' in one of two ways:
+ 1. The 'poll_delay' equals the number of seconds between the start of
+    successive poll requests
+ 2. The 'poll_delay' equals the number of seconds to wait between the end
+    of one poll request and the start of the next
 
 =cut
 
diff --git a/lib/Weasel/Session.pm b/lib/Weasel/Session.pm
index ce54475..2162681 100644
--- a/lib/Weasel/Session.pm
+++ b/lib/Weasel/Session.pm
@@ -97,6 +97,30 @@ sub _page_builder {
 }
 
 
+=item retry_timeout
+
+The number of seconds to poll for a condition to become true. Global
+setting for the C<wait_for> function.
+
+=cut
+
+has 'retry_timeout' => (is => 'rw',
+                        default => 15,
+                        isa => 'Num',
+    );
+
+=item poll_delay
+
+The number of seconds to wait between state polling attempts. Global
+setting for the C<wait_for> function.
+
+=cut
+
+has 'poll_delay' => (is => 'rw',
+                     default => 0.5,
+                     isa => 'Num',
+    );
+
 =back
 
 =head1 METHODS
@@ -243,17 +267,23 @@ sub tag_name {
     return $self->driver->tag_name($element->_id);
 }
 
-=item wait_for($callback)
+=item wait_for($callback, [ retry_timeout => $number,] [poll_delay => number])
+
+Waits until $callback->() returns true, or C<wait_timeout> expires -- whichever
+comes first.
 
-Waits until $callback->() returns true, or C<wait_timeout> expires
-(if the driver supports it) -- whichever comes first.x
+The arguments retry_timeout and poll_delay can be used to override the
+session-global settings for the duration of the call.
 
 =cut
 
 sub wait_for {
-    my ($self, $callback) = @_;
+    my ($self, $callback, %args) = @_;
 
-    $self->driver->wait_for($callback);
+    $self->driver->wait_for($callback,
+                            retry_timeout => $self->retry_timeout,
+                            poll_delay => $self->poll_delay,
+                            %args);
 }
 
 =item _wrap_widget($_id)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libweasel-perl.git



More information about the Pkg-perl-cvs-commits mailing list