New Features
CallContext / CallKwContext on *Object and *BoundModule — context-aware variants of Call / CallKw that respect context.Context cancellation and deadlines. If the context is cancelled before the Python call completes, the Go caller returns ctx.Err() immediately while the background goroutine cleans up automatically.
Example
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
result, err := fn.CallContext(ctx, arg1, arg2)
if errors.Is(err, context.DeadlineExceeded) {
// Python call took too long
}
Internal
- Extracted
Runtime.callKw internal helper to share logic between CallKw and CallKwContext.