wait

CasperJS waitForResource: how to get the resource i've waited for

人走茶凉 提交于 2019-12-01 11:40:54
casper.test.begin('Test foo', 1, function suite(test) { casper.start("http://www.foo.com", function() { casper.waitForResource("bar", function(resource) { casper.echo(resource.url); }); }); casper.run(function() { test.done(); }); }); casper.echo returns www.foo.com resource (the one in casper.start ), not the one with "bar". How can I get the resource i've waited for with waitForResource ? You actually waited for the "bar" resource. The problem is that resource inside the then callback function of waitForResource is actually the page resource of the last start or open ( thenOpen ) call. It

Wait animation “…” to appear over and over

耗尽温柔 提交于 2019-12-01 11:27:47
I'm trying to display a sort of loading animation, specifically three dots appearing over and over. I thought the below would work: import time, sys for i in range(9): time.sleep(0.2) x = i % 4 sys.stdout.write("." * x) sys.stdout.flush() However all it does is just gradually (and non-uniformly) load this: "........." Use \r the return character. This is because your cursor should return to the original position after you lapse the time import time, sys for i in range(15): sys.stdout.write(" ") x = i % 4 sys.stdout.write('\r' + "." * x ) time.sleep(0.5) sys.stdout.flush() 来源: https:/

CasperJS waitForResource: how to get the resource i've waited for

巧了我就是萌 提交于 2019-12-01 10:36:39
问题 casper.test.begin('Test foo', 1, function suite(test) { casper.start("http://www.foo.com", function() { casper.waitForResource("bar", function(resource) { casper.echo(resource.url); }); }); casper.run(function() { test.done(); }); }); casper.echo returns www.foo.com resource (the one in casper.start ), not the one with "bar". How can I get the resource i've waited for with waitForResource ? 回答1: You actually waited for the "bar" resource. The problem is that resource inside the then callback

Is there an activity indicator in Wicket?

我的未来我决定 提交于 2019-12-01 10:23:27
问题 I'll make this short: Is there a way / library in Wicket to show an activity indicator? You know, the spinning thing that moves while the user is waiting for something, or is it just a javascript thing? Thanks for your help. 回答1: If this is an ajax operation then you can look at the implementations of IAjaxIndicatorAware . These implementations will show a 'spinner' while the operation is processing. e.g. IndicatingAjaxButton and IndicatingAjaxLink You could also look at AjaxIndicatorAppender

Wait animation “…” to appear over and over

家住魔仙堡 提交于 2019-12-01 07:34:33
问题 I'm trying to display a sort of loading animation, specifically three dots appearing over and over. I thought the below would work: import time, sys for i in range(9): time.sleep(0.2) x = i % 4 sys.stdout.write("." * x) sys.stdout.flush() However all it does is just gradually (and non-uniformly) load this: "........." 回答1: Use \r the return character. This is because your cursor should return to the original position after you lapse the time import time, sys for i in range(15): sys.stdout

Thread Synchronization - How to execute threads alternatively

天涯浪子 提交于 2019-12-01 06:55:36
I have been trying to solve a problem involving thread communication using wait() and notify(). Basically i have 2 threads T1 and T2 and i want them to be executed in the following order T1 , T2, T1, T2 ..... How can i achieve that? Actual Problem: There are 2 threads T1 - which prints odd numbers (say 1 - 100) and T2 - which prints even numbers (1 - 100). Now, the output should be 1, 2, 3, 4 , 5 , .... 100 You describe a Producer-Consumer pattern. It's java implementations described in numerous java books including M.Grand "Patterns in Java. Volume I" and "Java 2: The Complete Reference" by

Bash script kill background (grand)children on Ctrl+C

时光毁灭记忆、已成空白 提交于 2019-12-01 06:07:53
I have a Bash script (Bash 3.2, Mac OS X 10.8) that invokes multiple Python scripts in parallel in order to better utilize multiple cores. Each Python script takes a really long time to complete. The problem is that if I hit Ctrl+C in the middle of the Bash script, the Python scripts do not actually get killed. How can I write the Bash script so that killing it will also kill all its background children? Here's my original "reduced test case". Unfortunately I seem to have reduced it so much that it no longer demonstrates the problem; my mistake. set -e cat >work.py <<EOF import sys, time for i

make PHP wait until a function completes?

喜你入骨 提交于 2019-12-01 06:06:28
Is there any way to make PHP wait until a function returns before continuing? This is my code: <?php set_time_limit(0); function waitforchange($nof) { $lfilemod=filemtime($nof); while(filemtime($nof) == $lfilemod) { clearstatcache(); usleep(10000); } } waitforchange('./blahblah.txt') sleep(5); echo 'done'; ?> It is supposed to wait until blahblah.txt changes, wait another five seconds after that, then print out "done", however, it prints out "done" after five seconds, regardless whether the file actually changed. PHP is single-threaded, which means that it executes one instruction at a time

Wait() and Notify() concepts - Java Multithreading

五迷三道 提交于 2019-12-01 05:47:40
问题 class Q { volatile boolean valueSet = false; volatile int n; synchronized int get () { if ( !valueSet ) { try { wait(); } catch ( InterruptedException e ) { System.out.println( "InterruptedException caught" ); } } System.out.println( "Got: " + n ); valueSet = false; notify(); return n; } synchronized void put ( int n ) { if ( valueSet ) { try { wait(); } catch ( InterruptedException e ) { System.out.println( "InterruptedException caught" ); } } this.n = n; valueSet = true; System.out.println(

How to pause for 5 seconds before drawing the next thing on Android?

谁说胖子不能爱 提交于 2019-12-01 05:35:55
Say I want to draw a line, then wait five seconds, then draw another line. I have a method like this: public void onDraw(Canvas canvas) { int w = canvas.getWidth(); int h = canvas.getHeight(); canvas.drawLine(w/2, 0, w/2, h-1, paint); // PAUSE FIVE SECONDS canvas.drawLine(0, h/2, w-1, h/2, paint); } How do I pause? Don't wait in onDraw method it's called in the UI thread and you'll block it. Use flags to handle which line will be drawn boolean shouldDrawSecondLine = false; public void setDrawSecondLine(boolean flag) { shouldDrawSecondLine = flag; } public void onDraw(Canvas canvas) { int w =