Get jobno and open log after sleeping
The previous code was obtaining the jobno and opening the log before any necessary sleeping, which two undesirable effects: 1. The "Starting job n" messages looked fairly random when jobs were delayed. 2. The initial batch of jobs were allocated not as hosts are actually available, but when hosts are available after a delay. For a fast job with some hosts having a large number of CPUs, this means the job could take unnecessarily long: e.g. imagine a 'hostA=1 hostB=99' with an instantaneous job (and connection) executing 100 jobs: all jobnos would be instantly grabbed by the 99 threads, but the last job on hostB wouldn't run for 99 DELAY periods, even though the optimal solution is 50 jobs each (and a total time of 50 DELAYs instead of 99 DELAYs). This fixes the problem by checking and obtaining a jobno after finishing the delay.
Showing with 13 additions and 11 deletions