Skip to content

Commit 5d18c19

Browse files
committed
windows compatibility
1 parent 961a6df commit 5d18c19

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/chuk_tool_processor/execution/strategies/inprocess_strategy.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import asyncio
2121
import inspect
2222
import os
23+
import platform
2324
from contextlib import asynccontextmanager
2425
from datetime import datetime, timezone
2526
from typing import Any, List, Optional, AsyncIterator, Set, Tuple
@@ -214,7 +215,7 @@ async def _stream_tool_call(
214215
error="System is shutting down",
215216
start_time=now,
216217
end_time=now,
217-
machine=os.uname().nodename,
218+
machine=platform.node(),
218219
pid=os.getpid(),
219220
)
220221
await queue.put(result)
@@ -232,7 +233,7 @@ async def _stream_tool_call(
232233
error=f"Tool '{call.tool}' not found in any namespace",
233234
start_time=now,
234235
end_time=now,
235-
machine=os.uname().nodename,
236+
machine=platform.node(),
236237
pid=os.getpid(),
237238
)
238239
await queue.put(result)
@@ -265,7 +266,7 @@ async def _stream_tool_call(
265266
error="Execution was cancelled",
266267
start_time=now,
267268
end_time=now,
268-
machine=os.uname().nodename,
269+
machine=platform.node(),
269270
pid=os.getpid(),
270271
)
271272
await queue.put(result)
@@ -279,7 +280,7 @@ async def _stream_tool_call(
279280
error=f"Error setting up execution: {e}",
280281
start_time=now,
281282
end_time=now,
282-
machine=os.uname().nodename,
283+
machine=platform.node(),
283284
pid=os.getpid(),
284285
)
285286
await queue.put(result)
@@ -304,7 +305,7 @@ async def _stream_with_timeout(
304305
timeout: Timeout in seconds (required)
305306
"""
306307
start_time = datetime.now(timezone.utc)
307-
machine = os.uname().nodename
308+
machine = platform.node()
308309
pid = os.getpid()
309310

310311
logger.debug("Streaming %s with %ss timeout", call.tool, timeout)
@@ -412,7 +413,7 @@ async def _execute_single_call(
412413
Tool execution result
413414
"""
414415
pid = os.getpid()
415-
machine = os.uname().nodename
416+
machine = platform.node()
416417
start = datetime.now(timezone.utc)
417418

418419
logger.debug("Executing %s with %ss timeout", call.tool, timeout)

src/chuk_tool_processor/execution/strategies/subprocess_strategy.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import functools
2121
import inspect
2222
import os
23+
import platform
2324
import pickle
2425
import signal
2526
import sys
@@ -82,7 +83,7 @@ def _serialized_tool_worker(
8283

8384
start_time = datetime.now(timezone.utc)
8485
pid = os.getpid()
85-
hostname = os.uname().nodename
86+
hostname = platform.node()
8687

8788
result_data = {
8889
"tool": tool_name,
@@ -290,7 +291,7 @@ async def run(
290291
error="System is shutting down",
291292
start_time=datetime.now(timezone.utc),
292293
end_time=datetime.now(timezone.utc),
293-
machine=os.uname().nodename,
294+
machine=platform.node(),
294295
pid=os.getpid(),
295296
)
296297
for call in calls
@@ -341,7 +342,7 @@ async def stream_run(
341342
error="System is shutting down",
342343
start_time=datetime.now(timezone.utc),
343344
end_time=datetime.now(timezone.utc),
344-
machine=os.uname().nodename,
345+
machine=platform.node(),
345346
pid=os.getpid(),
346347
)
347348
return
@@ -422,7 +423,7 @@ async def _execute_single_call(
422423
error=f"Tool '{call.tool}' not found in any namespace",
423424
start_time=start_time,
424425
end_time=datetime.now(timezone.utc),
425-
machine=os.uname().nodename,
426+
machine=platform.node(),
426427
pid=os.getpid(),
427428
)
428429

@@ -456,7 +457,7 @@ async def _execute_single_call(
456457
error=f"Tool serialization failed: {str(e)}",
457458
start_time=start_time,
458459
end_time=datetime.now(timezone.utc),
459-
machine=os.uname().nodename,
460+
machine=platform.node(),
460461
pid=os.getpid(),
461462
)
462463

@@ -504,7 +505,7 @@ async def _execute_single_call(
504505
error=result_data.get("error"),
505506
start_time=result_data.get("start_time", start_time),
506507
end_time=result_data.get("end_time", end_time),
507-
machine=result_data.get("machine", os.uname().nodename),
508+
machine=result_data.get("machine", platform.node()),
508509
pid=result_data.get("pid", os.getpid()),
509510
)
510511

@@ -520,7 +521,7 @@ async def _execute_single_call(
520521
error=f"Worker process timed out after {safety_timeout}s",
521522
start_time=start_time,
522523
end_time=end_time,
523-
machine=os.uname().nodename,
524+
machine=platform.node(),
524525
pid=os.getpid(),
525526
)
526527

@@ -536,7 +537,7 @@ async def _execute_single_call(
536537
error="Worker process crashed",
537538
start_time=start_time,
538539
end_time=datetime.now(timezone.utc),
539-
machine=os.uname().nodename,
540+
machine=platform.node(),
540541
pid=os.getpid(),
541542
)
542543

@@ -548,7 +549,7 @@ async def _execute_single_call(
548549
error="Execution was cancelled",
549550
start_time=start_time,
550551
end_time=datetime.now(timezone.utc),
551-
machine=os.uname().nodename,
552+
machine=platform.node(),
552553
pid=os.getpid(),
553554
)
554555

@@ -565,7 +566,7 @@ async def _execute_single_call(
565566
error=f"Error: {str(e)}",
566567
start_time=start_time,
567568
end_time=end_time,
568-
machine=os.uname().nodename,
569+
machine=platform.node(),
569570
pid=os.getpid(),
570571
)
571572

src/chuk_tool_processor/models/tool_result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import annotations
66

77
import os
8+
import platform
89
import uuid
910
from datetime import datetime, timezone
1011
from typing import Any, Dict, Optional, List
@@ -63,7 +64,7 @@ class ToolResult(BaseModel):
6364
description="UTC timestamp when execution finished"
6465
)
6566
machine: str = Field(
66-
default_factory=lambda: os.uname().nodename,
67+
default_factory=lambda: platform.node(),
6768
description="Hostname where the tool ran"
6869
)
6970
pid: int = Field(

0 commit comments

Comments
 (0)