Timeout question (newCommandTimeout and idling)

TLDR; Need a difference between a command timeout and an idle timeout

I currently have some java testNG tests that have 2 android emulators in-use. I setup (or reuse) these emulator appium connections in a @BeforeMethod (so before every test). The issue is that I use the first emulator in the first test, and the second emulator in the second test, and there are about 10 minutes in between the two tests (other tests are run, and lots of server-side stuff is going on, so I need to wait anyway). I’ve setup the newCommandTimeout to 20 minutes to handle the difference for the second emulator, so it doesn’t die off. Currently if I have a command that messes up, it takes 20 minutes to fail (instead of say, I want a 1 minute timeout for the command to fail / hang), but I still want an idle timeout.

  1. Can we get a feature to support the two different timeouts
    or
  2. Is there a better way to implement this knowing I can have an idling appium session for > 10 minutes before it’s needed for a subsequent test.

I have thought about setting up the appium java client at the beginning of the test, but I have several tests in the test class, and if any of the setups fail, I don’t want to fail the test, just skip it since it wouldn’t be failing something I’m trying to test.

Thanks,
Ben

i wrote ping functions to prevent driver stop while i do other stuff (just like you DB, emails or SMS).
not perfect but you can change to any by taking the idea.

private Boolean doPing_1 = false; // prevent server 1 from sleep
private Boolean doPing_2 = false; // prevent server 2 from sleep
public void startPhonePinging(int serverID) { //prevent phone, driver and server from stop
    System.out.println("   startPhonePinging: "+serverID);
    Thread t;
    if (serverID == 1) {
        doPing_1 = true;
        t = new Thread() {
            public void run() {
                try{Thread.sleep(20000);}catch(Exception e){}
                while (doPing_1) {
                    driver.getPageSource();
                    try{Thread.sleep(20000);}catch(Exception e){}
                }
            }
        };
    } else if (serverID == 2) {
        doPing_2 = true;
        t = new Thread() {
            public void run() {
                try{Thread.sleep(20000);}catch(Exception e){}
                while (doPing_2) {
                    driver_2.getPageSource();
                    try{Thread.sleep(20000);}catch(Exception e){}
                }
            }
        };
    } else {
        System.err.println("startPhonePinging(): ----------- ADD NEW SERVER! -----------");
        return;
    }
    t.start();
}
public void stopPhonePinging(int serverID) {
    if (serverID == 1) {
        doPing_1 = false;
    } else if (serverID == 2) {
        doPing_2 = false;
    } else {
        System.err.println("stopPhonePinging(): ----------- ADD NEW SERVER! -----------");
        return;
    }
}

Cool… good short-term idea. That should help out, and not require me to write a class that spawns off a thread that I can timeout for any driver calls, thanks!

-Ben

dont forget to add afterMethod for sure that we stop threads.

        stopPhonePinging(1);
        stopPhonePinging(2);