Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio.exceptions.CancelledError: Cancelled by cancel scope 7ff72233f610 #18

Open
sunbeibei-hub opened this issue Feb 1, 2024 · 3 comments

Comments

@sunbeibei-hub
Copy link

@app.post("/api/xtts_stream")
def gpt_xtts_stream(inputs: xtts_stream_inputs):
    try:
        speaker["text"] = inputs.text
        speaker['language'] = inputs.language
        speaker['stream_chunk_size'] = inputs.stream_chunk_size

        res = requests.post(
            f"http://0.0.0.0:8004/tts_stream",
            json=speaker,
            stream=True,
        )

        def iterms_gene(res):
            if res.status_code != 200:
                print("Error:", res.text)
                sys.exit(1)
            first = True
            for chunk in res.iter_content(chunk_size=512):
                if first:
                    first = False
                if chunk:
                    yield chunk
        # 返回音频流文件
        return StreamingResponse(iterms_gene(res), media_type="audio/wav")
    except Exception as e:
        logging.error(f"Error: {e}")
        return {"error": str(e)}

i want to use main.py in /tts_stream, so up.
but, i get down error:

ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 259, in call
await wrap(partial(self.listen_for_disconnect, receive))
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 255, in wrap
await func()
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 232, in listen_for_disconnect
message = await receive()
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 538, in receive
await self.message_event.wait()
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7ff72233f610

During handling of the above exception, another exception occurred:

  • Exception Group Traceback (most recent call last):
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
    | return await self.app(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/applications.py", line 116, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/middleware/errors.py", line 186, in call
    | raise exc
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/middleware/errors.py", line 164, in call
    | await self.app(scope, receive, _send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
    | raise exc
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
    | raise exc
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/routing.py", line 746, in call
    | await route.handle(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/routing.py", line 75, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
    | raise exc
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/routing.py", line 73, in app
    | await response(scope, receive, send)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 259, in call
    | await wrap(partial(self.listen_for_disconnect, receive))
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 678, in aexit
    | raise BaseExceptionGroup(
    | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 255, in wrap
    | await func()
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 244, in stream_response
    | async for chunk in self.body_iterator:
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/concurrency.py", line 57, in iterate_in_threadpool
    | yield await anyio.to_thread.run_sync(_next, iterator)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/anyio/to_thread.py", line 56, in run_sync
    | return await get_async_backend().run_sync_in_worker_thread(
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 2134, in run_sync_in_worker_thread
    | return await future
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 851, in run
    | result = context.run(func, *args)
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/concurrency.py", line 47, in _next
    | return next(iterator)
    | File "/data/search/bei/TTS/xtts-streaming-server/server/main.py", line 131, in predict_streaming_generator
    | for i, chunk in enumerate(chunks):
    | File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 35, in generator_context
    | response = gen.send(None)
    | File "/data/search/bei/TTS/TTS/tts/models/xtts.py", line 633, in inference_stream
    | gpt_cond_latent = gpt_cond_latent.to(self.device)
    | RuntimeError: CUDA error: device-side assert triggered
    | CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
    | For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
    | Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.
    |
    +------------------------------------

main.py don`t change!

@rvuyyuru2
Copy link

same issue what to do how to fix

@henvu50
Copy link

henvu50 commented Feb 20, 2024

same issue here as well

@javi22020
Copy link

Same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants