Skip to content

Commit 269b6fc

Browse files
committed
Implement Windows task time limit
1 parent e096dcf commit 269b6fc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/AsyncTask.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function __construct(Closure|AsyncTaskInterface $theTask)
5555
public function run(): void
5656
{
5757
// todo startup configs
58+
if (OsInfo::isWindows()) {
59+
// windows can just use PHP's time limit
60+
set_time_limit($this->timeLimit);
61+
}
5862

5963
// then, execute the task itself
6064
if ($this->theTask instanceof SerializableClosure) {
@@ -84,6 +88,7 @@ public function start(): void
8488
if (OsInfo::isWindows()) {
8589
// basically, in windows, it is too tedioous to check whether we are in cmd or ps,
8690
// but we require cmd (ps won't work here), so might as well force cmd like this
91+
// windows has real max time limit
8792
$this->runnerProcess = Process::quietly()->start("cmd /c start /b $baseCommand");
8893
return;
8994
}

0 commit comments

Comments
 (0)