Skip to content

Commit f70cf33

Browse files
committed
usleep Values larger than 1000000 may not be supported by the operating system. split to int and microseconds
1 parent deb0e37 commit f70cf33

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/CLI/Console.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,16 @@ static public function loop(callable $callback, $sleep = 1 /* seconds */, callab
209209
}
210210
}
211211

212-
usleep($sleep * 1000000);
212+
$intSeconds = intval($sleep);
213+
$microSeconds = ($sleep - $intSeconds) * 1000000;
214+
215+
if($intSeconds > 0) {
216+
sleep($intSeconds);
217+
}
218+
219+
if($microSeconds > 0) {
220+
usleep($microSeconds);
221+
}
213222

214223
$time = $time + $sleep;
215224

0 commit comments

Comments
 (0)