Skip to content

Commit 7c1d4bc

Browse files
Merge pull request #229 from MervinPraison/claude/issue-227-20260422-1640
docs: document PRAISONAI_RUN_SYNC_TIMEOUT and shutdown() API (fixes #227)
2 parents 228d5c7 + 99fa8d2 commit 7c1d4bc

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

docs/cli/env.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ praisonai env show
3333
praisonai env check
3434
```
3535

36+
## Related Environment Variables
37+
38+
PraisonAI supports several environment variables for configuration and security:
39+
40+
| Variable | Purpose |
41+
|----------|---------|
42+
| `PRAISONAI_ALLOW_LOCAL_TOOLS` | Enable local tools.py file loading |
43+
| `PRAISONAI_ALLOW_JOB_WORKFLOWS` | Enable job workflow execution |
44+
| `PRAISONAI_BROWSER_ALLOW_REMOTE` | Enable remote browser access |
45+
| `PRAISONAI_RUN_SYNC_TIMEOUT` | Default timeout for async operations (seconds) |
46+
47+
For complete details and security implications, see [Security Environment Variables](/docs/features/security-environment-variables).
48+
3649
## See Also
3750

3851
- [Config](/docs/cli/config) - Configuration management

docs/features/gateway.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,21 @@ session_config = SessionConfig(
337337

338338
---
339339

340+
## Graceful Shutdown
341+
342+
Long-running servers can stop the wrapper's background async loop explicitly:
343+
344+
```python
345+
from praisonai._async_bridge import shutdown
346+
347+
# On SIGTERM / server stop
348+
shutdown()
349+
```
350+
351+
`shutdown()` is also registered via `atexit`, so it runs automatically on interpreter exit. Call it manually when you need deterministic cleanup (flushing telemetry exporters, closing async HTTP/DB clients) before the process exits.
352+
353+
---
354+
340355
## CLI Commands
341356

342357
```bash

docs/features/security-environment-variables.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ unset PRAISONAI_ALLOW_LOCAL_TOOLS
104104
- Agent API calls
105105
- Real-time UI interactions
106106

107+
As of recent PraisonAI versions, the `PRAISONAI_ALLOW_LOCAL_TOOLS` gate is enforced consistently across the CLI (`praisonai run`), YAML workflows, and Python (`AgentsGenerator`) entry points. Previously it was only enforced on one path.
108+
107109
**Usage Example**:
108110
```python
109111
from praisonaiagents import Agent
@@ -185,6 +187,22 @@ server = BrowserServer(host="0.0.0.0", port=8080)
185187
server.start()
186188
```
187189

190+
### PRAISONAI_RUN_SYNC_TIMEOUT
191+
192+
Default maximum seconds the wrapper's sync-to-async bridge will wait for a coroutine to complete.
193+
194+
**Default:** `300` (5 minutes)
195+
196+
```bash
197+
# Tighten for latency-sensitive servers
198+
export PRAISONAI_RUN_SYNC_TIMEOUT=30
199+
200+
# Loosen for long-running batch jobs
201+
export PRAISONAI_RUN_SYNC_TIMEOUT=3600
202+
```
203+
204+
Applies to every `praisonai` CLI entry and wrapper-based server (gateway, a2u, mcp_server, scheduler). The SDK (`praisonaiagents`) uses a separate bridge — see [Async Bridge](/docs/features/async-bridge).
205+
188206
---
189207

190208
## Common Patterns
@@ -196,6 +214,7 @@ server.start()
196214
export PRAISONAI_ALLOW_LOCAL_TOOLS=true
197215
export PRAISONAI_ALLOW_JOB_WORKFLOWS=true
198216
export PRAISONAI_BROWSER_ALLOW_REMOTE=true
217+
export PRAISONAI_RUN_SYNC_TIMEOUT=30
199218

200219
# Add to ~/.bashrc or ~/.zshrc for persistence
201220
echo 'export PRAISONAI_ALLOW_LOCAL_TOOLS=true' >> ~/.bashrc
@@ -208,13 +227,15 @@ echo 'export PRAISONAI_ALLOW_LOCAL_TOOLS=true' >> ~/.bashrc
208227
unset PRAISONAI_ALLOW_LOCAL_TOOLS
209228
unset PRAISONAI_ALLOW_JOB_WORKFLOWS
210229
unset PRAISONAI_BROWSER_ALLOW_REMOTE
230+
export PRAISONAI_RUN_SYNC_TIMEOUT=300
211231

212232
# Or use systemd service with secure environment
213233
# /etc/systemd/system/praisonai.service
214234
[Service]
215235
Environment="PRAISONAI_ALLOW_LOCAL_TOOLS=false"
216236
Environment="PRAISONAI_ALLOW_JOB_WORKFLOWS=false"
217237
Environment="PRAISONAI_BROWSER_ALLOW_REMOTE=false"
238+
Environment="PRAISONAI_RUN_SYNC_TIMEOUT=300"
218239
```
219240
</Tab>
220241

@@ -258,6 +279,7 @@ Check if you use any of these features:
258279
export PRAISONAI_ALLOW_LOCAL_TOOLS=true # If you use tools.py
259280
export PRAISONAI_ALLOW_JOB_WORKFLOWS=true # If you use job workflows
260281
export PRAISONAI_BROWSER_ALLOW_REMOTE=true # If you bind browser to 0.0.0.0
282+
export PRAISONAI_RUN_SYNC_TIMEOUT=300 # Adjust timeout as needed
261283
```
262284
</Step>
263285

0 commit comments

Comments
 (0)