Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion redislite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ 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)
# Use execute_command to avoid async/sync confusion
self.execute_command('SHUTDOWN', 'SAVE', 'NOW', 'FORCE')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why not verify in runtime?

# Check if it's a coroutine function
if inspect.iscoroutinefunction(shutdown):
    await shutdown()
else:
    shutdown()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! I've implemented the runtime check approach in commit ced665b.

The code now checks inspect.iscoroutinefunction(self.shutdown) at runtime:

  • If it's a coroutine function (async), uses execute_command (always synchronous)
  • Otherwise, calls self.shutdown() with the original parameters

This preserves the original method signature while handling both sync and async cases gracefully. All tests pass without warnings.

try: # pragma: no cover
process = psutil.Process(pid)
except psutil.NoSuchProcess: # pragma: no cover
Expand Down
4 changes: 2 additions & 2 deletions redislite/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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:")
Expand Down
Loading