Skip to content

PytestUnraisableExceptionWarning from asycio client #2660

Closed
@ahgraber

Description

@ahgraber

Version: What redis-py and what redis version is the issue happening on?

redis-py 4.3.4 and 4.5.3
redis 7.0.9

Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure)

Python 3.9.16 | packaged by conda-forge
[Clang 14.0.6 ] on darwin 

Occurs in both arm64 and Rosetta amd64 environments.

Description: Description of your issue, stack traces from errors and code that reproduces the issue

When running unit tests on a redis.asyncio.Redis object, I notice I keep getting PytestUnraisableExceptionWarning that is raised because of del() calling self.close() in Redis class, as the self.connection attribute was not set due to early failure in the Redis() constructor.

  /Users/me/mambaforge/envs/x86_ds_utils/lib/python3.9/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <function Redis.__del__ at 0x17c0919d0>
  
  Traceback (most recent call last):
    File "/Users/me/mambaforge/envs/x86_ds_utils/lib/python3.9/site-packages/redis/asyncio/client.py", line 458, in __del__
      if self.connection is not None:
  AttributeError: 'RedisCache' object has no attribute 'connection'
  
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

I think this was fixed in the standard (non-async) Redis in #1458

Metadata

Metadata

Assignees

Labels

maintenanceMaintenance (CI, Releases, etc)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions