-
Notifications
You must be signed in to change notification settings - Fork 4
Fix RuntimeWarning and DeprecationWarning in test suite #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
d48d3b6
36c005b
3bd6271
501715c
ced665b
ca69c14
09bd73c
a212180
289716a
1346ec0
f6c9525
d72930c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| :class:`redis.StrictRedis()` classes. | ||
| """ | ||
| import atexit | ||
| import inspect | ||
| import json | ||
| import logging | ||
| import os | ||
|
|
@@ -109,7 +110,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 execute_command which is always synchronous | ||
| self.execute_command('SHUTDOWN', 'SAVE', 'NOW', 'FORCE') | ||
| else: | ||
|
Comment on lines
+114
to
+118
|
||
| # 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot don't you think it's better to use asyncio when calling the async API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Using
asyncio.run()is the proper way to handle the async shutdown. I've updated the code in commit 09bd73c to useasyncio.run(self.shutdown(save=True, now=True, force=True))instead of falling back toexecute_command.This properly awaits the async method when detected, maintaining the original method signature and behavior. All tests pass without warnings.