Skip to content

Commit 8c3b4f5

Browse files
committed
set accessed at the proper time, clear buffers to save memory
1 parent 4734b90 commit 8c3b4f5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/async_bash_mcp/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ async def poll_process(
219219
process_info.stdout_position = len(process_info.stdout_buffer)
220220
process_info.stderr_position = len(process_info.stderr_buffer)
221221

222-
# Mark as accessed
223-
process_info.accessed = True
224222

225223
elapsed_time = (time.time() - process_info.start_time) * 1000
226224

@@ -232,6 +230,10 @@ async def poll_process(
232230
}
233231

234232
if process_info.finished:
233+
# Mark as accessed
234+
process_info.accessed = True
235+
process_info.stdout_buffer = ""
236+
process_info.stderr_buffer = ""
235237
result["exitCode"] = process_info.exit_code
236238

237239
return result
@@ -311,6 +313,16 @@ async def spawn(
311313
312314
Returns a unique process ID that can be used to check progress with the poll tool. **ALWAYS POLL THE PROCESS AFTER SPAWNING**.
313315
316+
Multiple commands can be spawned in parallel and independently polled. If the task requires running independent bash commands, run them in parrallel.
317+
318+
Example:
319+
320+
1. User requests the results of `test a` and `test b`
321+
2. spawn `test a`
322+
3. spawn `test b`
323+
4. while test a is running: poll test a
324+
5. while test b is running: poll test b
325+
314326
Args:
315327
command: The bash command to execute
316328
cwd: Optional working directory path (defaults to current directory)

0 commit comments

Comments
 (0)