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

v2 2.0.0b4 版本,获取加密配置文件后协程任务报错:Task was destroyed but it is pending! #200

Open
alan-hanx opened this issue Dec 25, 2024 · 0 comments

Comments

@alan-hanx
Copy link

代码:

import asyncio

from v2.nacos import NacosNamingService, ClientConfigBuilder, GRPCConfig, Instance, SubscribeServiceParam, \
    RegisterInstanceParam, DeregisterInstanceParam, BatchRegisterInstanceParam, GetServiceParam, ListServiceParam, \
    ListInstanceParam, NacosConfigService, ConfigParam, KMSConfig


async def fetch_config():
    client_config = (ClientConfigBuilder()
                     .access_key("")
                     .secret_key("")
                     .namespace_id("")
                     .server_address("")
                     .log_level('INFO')
                     .grpc_config(GRPCConfig(grpc_timeout=5000))
                     .build())

    kms_config = KMSConfig(
        enabled=True,
        endpoint="",
        access_key="",
        secret_key=""
    )
    client_config.set_kms_config(kms_config)

    config_client = await NacosConfigService.create_config_service(client_config)

    content = await config_client.get_config(ConfigParam(
        data_id="cipher-kms-aes-256-test",
        group="test",
        type="json",
        kms_key_id="alias/acs/mse"
    ))

    await config_client.shutdown()

    return content

def main():
    loop = asyncio.get_event_loop()
    try:
        result = loop.run_until_complete(fetch_config())
        print("Config Content:", result)
    finally:
        loop.close()

if __name__ == "__main__":
    main()

协程错误信息:

Task was destroyed but it is pending!
task: <Task pending name='Task-10' coro=<GrpcClient._server_request_watcher() running at D:\project\python\chatmfc-app\venv\Lib\site-packages\v2\nacos\transport\grpc_client.py:138> wait_for=<Task finished name='Task-11' coro=<StreamStreamCall._prepare_rpc() done, defined at D:\project\python\chatmfc-app\venv\Lib\site-packages\grpc\aio\_call.py:751> result=None>>
Task was destroyed but it is pending!
task: <Task pending name='Task-8' coro=<RpcClient.health_check_periodically() running at D:\project\python\chatmfc-app\venv\Lib\site-packages\v2\nacos\transport\rpc_client.py:121> wait_for=<Future finished result=None>>
Task was destroyed but it is pending!
task: <Task pending name='Task-7' coro=<RpcClient.reconnection_handler() running at D:\project\python\chatmfc-app\venv\Lib\site-packages\v2\nacos\transport\rpc_client.py:147> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Exception ignored in: <coroutine object RpcClient.reconnection_handler at 0x0000020F98E68AE0>
Traceback (most recent call last):
  File "D:\project\python\chatmfc-app\venv\Lib\site-packages\v2\nacos\transport\rpc_client.py", line 147, in reconnection_handler
    ctx = await self.reconnection_chan.get()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\asyncio\queues.py", line 160, in get
    getter.cancel()  # Just in case getter is not done yet.
    ^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 761, in call_soon
    self._check_closed()
  File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

...获取配置文件信息省略。
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