Skip to content
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

Wrap partial in enum.member for Python 3.11+ #238

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mweinelt
Copy link

@mweinelt mweinelt commented Jan 4, 2025

Fixes the following warning and the resulting test errors on Python 3.13.

functools.partial will be a method descriptor in future Python versions;
wrap it in enum.member() if you want to preserve the old behavior

Fixes the following warning and the resulting test errors on Python 3.13.

> functools.partial will be a method descriptor in future Python versions;
> wrap it in enum.member() if you want to preserve the old behavior
@mweinelt
Copy link
Author

mweinelt commented Jan 4, 2025

The remaining error seems to be

RuntimeWarning("coroutine method 'aclose' of 'AdbDeviceAsync.streaming_shell' was never awaited")

python/cpython#117536

@FliegendeWurst
Copy link

That warning can be worked around by adding await asyncio.sleep(0), apparently. It would be better to close the stream explicitly of course.

@mweinelt
Copy link
Author

mweinelt commented Jan 7, 2025

That warning can be worked around by adding await asyncio.sleep(0), apparently. It would be better to close the stream explicitly of course.

I tried the following change, but it didn't help.

diff --git a/adb_shell/adb_device_async.py b/adb_shell/adb_device_async.py
index 84ce523..c8cc170 100644
--- a/adb_shell/adb_device_async.py
+++ b/adb_shell/adb_device_async.py
@@ -904,8 +904,12 @@ class AdbDeviceAsync(object):
         if not self.available:
             raise exceptions.AdbConnectionError("ADB command not sent because a connection to the device has not been established.  (Did you call `AdbDeviceAsync.connect()`?)")
 
-        async for line in self._streaming_service(b'shell', command.encode('utf8'), transport_timeout_s, read_timeout_s, decode):
-            yield line
+        agen = self._streaming_service(b'shell', command.encode('utf8'), transport_timeout_s, read_timeout_s, decode)
+        try:
+            async for line in agen:
+                yield line
+        finally:
+            await agen.aclose()
 
     # ======================================================================= #
     #                                                                         #

3.13 is the latest version and 3.7/3.8 have both reached EOL..
If they are caught and we raise RuntimeError those warnings will not be
visible anymore, which makes noticing and fixing them so much harder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants