The Wayback Machine - https://web.archive.org/web/20201020071718/https://github.com/google/python-fire/pull/127
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

Run asyncio coroutines #127

Open
wants to merge 5 commits into
base: master
from
Open

Run asyncio coroutines #127

wants to merge 5 commits into from

Conversation

@robweiss
Copy link

@robweiss robweiss commented Jun 14, 2018

This determines whether a function is a coroutine runs it accordingly

@robweiss robweiss force-pushed the robweiss:run_coroutines branch from b25fa2f to c1d4748 Jun 14, 2018
@robweiss robweiss force-pushed the robweiss:run_coroutines branch from c1d4748 to b35e367 Jun 14, 2018
@dbieber dbieber force-pushed the google:master branch from ffbfa51 to 4695f34 Dec 5, 2019
@dbieber
Copy link
Member

@dbieber dbieber commented Feb 28, 2020

Thanks for the submission, this looks good.

[If you're still around, I know it's been a while since you opened the PR,] can you tell us a bit more about how you're using this? I haven't used asyncio before, and want a better understanding of how this will likely be used.

@dbieber
Copy link
Member

@dbieber dbieber commented Feb 28, 2020

We're going to introduce this soon

@dbieber dbieber closed this Feb 28, 2020
@robweiss
Copy link
Author

@robweiss robweiss commented Feb 28, 2020

Thanks for the submission, this looks good.

[If you're still around, I know it's been a while since you opened the PR,] can you tell us a bit more about how you're using this? I haven't used asyncio before, and want a better understanding of how this will likely be used.

Hi David, thanks for taking a look. I have several classes that define async functions. These functions are normally awaited on in the standard execution of the program, but sometimes it's useful to use the CLI via Fire to execute these functions individually. As a workaround, I've been creating sync_<func> methods that do the equivalent of asyncio.run_until_complete(<func>()), but figured it would be more elegant if Fire supported this natively

@dbieber
Copy link
Member

@dbieber dbieber commented Feb 28, 2020

One thing I'm wondering is: is there ever a time that you'd want to operate on the result of <func>() directly (where is a coroutine) by accessing one of its members?

@dbieber dbieber reopened this Feb 29, 2020
@dbieber dbieber added the cla: yes label Feb 29, 2020
@dbieber
Copy link
Member

@dbieber dbieber commented Mar 4, 2020

fyi iscoroutinefunction fails when passed an lru_cache decorated function.
AttributeError: 'functools._lru_cache_wrapper' object has no attribute '__code__'
We'll need to wrap iscoroutinefunction to catch errors, and make sure this doesn't slow down standard usage of Fire too much (shouldn't be an issue).

@dbieber
Copy link
Member

@dbieber dbieber commented Mar 4, 2020

Also inspect.findsource fails on something in the testFireAsyncio testcase with an IndexError which may end up being Python bug (but we'll adapt Fire to handle it) since the documentation says findsource should only raise OSErrors. Will have to dig into it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.