Skip to content

[Bug] Streaming chat completion crashes with RuntimeError (Python 3.13 / anyio cancel scope) #6483

Closed

Description

@herlesupreeth

When a streaming chat completion request is sent to Unsloth Studio's OpenAI-compatible endpoint (POST /v1/chat/completions) on macOS with Python 3.13, the server crashes with:

RuntimeError: Attempted to exit a cancel scope that isn't the current tasks's current cancel scope

Note: Please do not remove the questions. Answer beside them.

  1. Did you update? pip install --upgrade unsloth unsloth_zoo - No
  2. Colab or Kaggle or local / cloud - Local
  3. Number GPUs used, use nvidia-smi - Macbook Pro M5 Pro
  4. Which notebook? Please link! - None
  5. Which Unsloth version, TRL version, transformers version, PyTorch version? Unsloth version v0.1.47-beta
  6. Which trainer? SFTTrainer, GRPOTrainer etc - None

Environment

Python 3.13
GPU - Apple Silicon
Model - unsloth/Qwen3.5-4B-MTP-GGUF
Transformers - 5.10.2
llama.cpp - unslothai/llama.cpp@b9704-mix-2d6bd50
anyio - 4.14.0

Steps to Reproduce

  1. Launch unsloth studio
  2. Load a GGUF model (e.g., unsloth/Qwen3.5-4B-MTP-GGUF)
  3. Configure copilot in VS Code to point to the local OpenAI endpoint: http://127.0.0.1:8888/v1/chat/completions
  4. Give a prompt in copilot chat window
  5. The attached error appears

unsloth_crash.log

Potential solution

Installing previous release of python anyio package does not result in crash
pip install anyio==4.13.0

Activity

  1. wuyuanyi135 commented on Jun 19, 2026

    @wuyuanyi135

    confirm downgrade fixes the exception spamming

  2. added 3 commits that reference this issue on Jun 22, 2026
    f10e47f
    65c8a88
    1ffffc1
  3. added a commit that references this issue on Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions