project-chip / certification-tool

A test harness and tooling designed to simplify development, testing, and certification for devices, guided by the Connectivity Standards Alliance.
https://csa-iot.org/
Apache License 2.0
28 stars 15 forks source link

[Bug] CLI Blocked by Unclosed HTTPX Client After An Error #155

Closed antonio-amjr closed 6 months ago

antonio-amjr commented 6 months ago

Describe the bug

Attention

This issue was already investigated, a solution patch was already tested and a new PR will be done immediately to solve the problem

Description

When using the CLI application, some errors may cause an exception to be triggered. The exception logic will currently skip the HTTPx client destruction, resulting in the following error:

[...] /httpx/_client.py:1978: UserWarning: Unclosed <httpx.AsyncClient object at 0xffffb95852a0>. See https://www.python-httpx.org/async/#opening-and-closing-clients for details.

This issue blocks the user from using the CLI app again until the HTTPx client is closed, and the service destruction it's not trivial.

Steps to reproduce the behavior

For instance, we may:

  1. Pre-requirements for CLI (config.json, poetry, etc.)
  2. Run a test with a wrong parameter (e.g ./cli.sh run-tests --project-id 1 --selected-tests '{"automated_and_semi_automated":{"FirstChipToolSuite":{"TC_BINFO_1_1":1}}}')
  3. Run one or more time again to receive the error mentioned in the description.

But any error that triggers an exception will do (e.g. project operations like creation, deletion or printing)

Expected behavior

It's expected that the user may use the CLI application again after an error occurs, adjusting the CLI command as needed.

Log files

No response

PICS file

No response

Screenshots

Screenshot 2024-01-24 at 14 19 10

Environment

No response

Additional Information

No response