-
Notifications
You must be signed in to change notification settings - Fork 322
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
Async for files.py functions #586
base: main
Are you sure you want to change the base?
Conversation
@@ -97,6 +111,10 @@ def list_files(page_size=100) -> Iterable[file_types.File]: | |||
yield file_types.File(proto) | |||
|
|||
|
|||
async def list_files_async(*args, **kwargs): |
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.
I think this will fail because we want an async iterator to be returned here.
Can you copy the list_files code and add the missing async
s?
@@ -105,6 +123,10 @@ def get_file(name: str) -> file_types.File: | |||
return file_types.File(client.get_file(name=name)) | |||
|
|||
|
|||
async def get_file_async(*args, **kwargs): | |||
return await asyncio.to_thread(get_file, *args, **kwargs) |
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.
We have an async client, we should use it. Let's copy-paste the code, and add the missing async
s
@@ -114,3 +136,7 @@ def delete_file(name: str | file_types.File | protos.File): | |||
request = protos.DeleteFileRequest(name=name) | |||
client = get_default_file_client() | |||
client.delete_file(request=request) | |||
|
|||
|
|||
async def delete_file_async(*args, **kwargs): |
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.
Same.
@@ -127,5 +130,29 @@ def test_files_delete(self): | |||
# [END files_delete] | |||
|
|||
|
|||
class AsyncTests(absltest.TestCase, unittest.IsolatedAsyncioTestCase): |
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.
We should test all the methods, I think list is broken right now.
Added
asyncio
methods for all the file methods.However, how should we test these
asyncio
methods?