diff --git a/redislite/client.py b/redislite/client.py index c3e9741..71469cd 100644 --- a/redislite/client.py +++ b/redislite/client.py @@ -10,7 +10,9 @@ they are functionally identical to the :class:`redis.Redis()` and :class:`redis.StrictRedis()` classes. """ +import asyncio import atexit +import inspect import json import logging import os @@ -109,7 +111,13 @@ def _cleanup(self, sys_modules=None): if getattr(self, '_async_managed', False): logger.debug('Skipping shutdown for async-managed client') return # Let async wrapper handle shutdown - self.shutdown(save=True, now=True, force=True) + # Check if shutdown is a coroutine function to avoid async/sync confusion + if hasattr(self, 'shutdown') and inspect.iscoroutinefunction(self.shutdown): + # If it's async, use asyncio.run to properly await it + asyncio.run(self.shutdown(save=True, now=True, force=True)) + else: + # Use the normal shutdown method + self.shutdown(save=True, now=True, force=True) try: # pragma: no cover process = psutil.Process(pid) except psutil.NoSuchProcess: # pragma: no cover diff --git a/redislite/debug.py b/redislite/debug.py index 6941dbe..710e07a 100644 --- a/redislite/debug.py +++ b/redislite/debug.py @@ -45,8 +45,8 @@ the module and it's build information. """ from __future__ import print_function -from distutils.spawn import find_executable import os +import shutil from .__init__ import __version__, __git_version__, __source_url__, \ __git_hash__, __git_origin__, __git_branch__, __redis_server_info__, \ __redis_executable__ @@ -58,7 +58,7 @@ def debug_info_list(): :return: """ info = [] - redis_server = find_executable('redis-server') + redis_server = shutil.which('redis-server') if __redis_executable__: # pragma: no cover redis_server = __redis_executable__ info.append("Redislite debug information:")