Skip to content

PytestUnraisableExceptionWarning from asycio client #2692

Closed
@ahgraber

Description

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

redis-py 4.3.4, 4.5.3, 4.5.4
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 Redis.del(), 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))

This is the same issue as #2660; the fix #2669 did not resolve this particular AttributeError.
The issue is in Redis.__del__() around line 458, where self.connection is not initialized.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions