[pve-devel] [PATCH common] add upid_wait method

Dietmar Maurer dietmar at proxmox.com
Fri Jan 22 17:32:00 CET 2016


> As sleep returns the seconds actually slept we could save the return 
> value after the sleep call
> and only call waitfunc if we slept for $sleep_intervall seconds? or 
> checking if $! != EINTR.
> 
> Or is there a better way?

I usually implement and use a sleep_until() command:

sub sleep_until {
   my ($self, $end_time) = @_;

   for (;;) {
       my $cur_time = time();

       last if $cur_time >= $end_time;

       CORE::sleep(1);
   }
}

I guess you need to adopt that for shorter periods (less that 1 second).

We already have/use that code in src/PVE/HA/Env.pm 




More information about the pve-devel mailing list