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

设置压测开关之后调用异步推理函数抛出异常:RuntimeError: Cannot run the event loop while another loop is running #518

Open
Dobiichi-Origami opened this issue May 13, 2024 · 0 comments

Comments

@Dobiichi-Origami
Copy link
Collaborator

Dobiichi-Origami commented May 13, 2024

System Info

Exception in thread Thread-3 (_warmup_procedure):
Traceback (most recent call last):
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/pengyiyang/Desktop/github/bce-qianfan-sdk/python/qianfan/resources/rate_limiter.py", line 387, in _warmup_procedure
    loop.run_until_complete(self._async_limiter.acquire(query_per_period))
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/asyncio/base_events.py", line 625, in run_until_complete
    self._check_running()
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/asyncio/base_events.py", line 586, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/threading.py:1018: RuntimeWarning: coroutine 'AsyncLimiter.acquire' was never awaited
  self._invoke_excepthook(self)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Exception in thread Thread-4 (_warmup_procedure):
Traceback (most recent call last):
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/pengyiyang/Desktop/github/bce-qianfan-sdk/python/qianfan/resources/rate_limiter.py", line 387, in _warmup_procedure
    loop.run_until_complete(self._async_limiter.acquire(query_per_period))
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/asyncio/base_events.py", line 625, in run_until_complete
    self._check_running()
  File "/Users/pengyiyang/miniconda3/envs/bce-qianfan-sdk-new/lib/python3.10/asyncio/base_events.py", line 586, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running

Reproduction

import asyncio
import os

os.environ['QIANFAN_ENABLE_STRESS_TEST'] = "true"

from qianfan import ChatCompletion

cc = ChatCompletion(endpoint="completions")

messages = [{"content": "你好,你是谁", "role": "user"}]

print(asyncio.run(cc.ado(messages)))
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

1 participant