Skip to content

Commit

Permalink
Merge pull request #300 from jolicode/timeoutfix
Browse files Browse the repository at this point in the history
feat(timeout): Remove the default timeout of 60s
  • Loading branch information
pyrech committed Feb 28, 2024
2 parents e0a7aeb + b1654ac commit 82f4710
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

* Add a `yaml_dump()` function to dump any PHP value to a YAML string
* Add a `yaml_parse()` function to parse a YAML string to a PHP value
* Remove the default timeout of 60 seconds from the Context

## 0.13.1 (2024-02-27)

Expand Down
18 changes: 3 additions & 15 deletions doc/getting-started/run.md
Expand Up @@ -188,7 +188,8 @@ function cs(): int
## Timeout

By default, Castor will use a 60 seconds timeout on all your `run()` calls.
By default, Castor allow your `run()` calls to go indefinitly.

If you want to tweak that you need to set the `timeout` argument.

```php
Expand All @@ -203,20 +204,7 @@ function foo(): void
}
```

This process will have a 2 minutes timeout. If you want to disable that feature,
you need to set the timeout to `0`.

```php
use Castor\Attribute\AsTask;

use function Castor\run;

#[AsTask()]
function foo(): void
{
run('echo "bar"', timeout: 0);
}
```
This process will have a 2 minutes timeout.

> [!TIP]
> Related example: [wait_for.php](https://github.com/jolicode/castor/blob/main/examples/wait_for.php)
Expand Down
2 changes: 1 addition & 1 deletion src/Context.php
Expand Up @@ -17,7 +17,7 @@ public function __construct(
?string $currentDirectory = null,
public readonly bool $tty = false,
public readonly bool $pty = true,
public readonly float|null $timeout = 60,
public readonly float|null $timeout = null,
public readonly bool $quiet = false,
public readonly bool $allowFailure = false,
public readonly bool $notify = false,
Expand Down

0 comments on commit 82f4710

Please sign in to comment.