Skip to content

Conversation

@robweiss
Copy link
Contributor

This determines whether a function is a coroutine runs it accordingly

@dbieber
Copy link
Collaborator

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
Collaborator

dbieber commented Feb 28, 2020

We're going to introduce this soon

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

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
Collaborator

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 Author has signed CLA label Feb 29, 2020
@dbieber
Copy link
Collaborator

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
Collaborator

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.

python-fire-bot pushed a commit that referenced this pull request Dec 16, 2020
COPYBARA_INTEGRATE_REVIEW=#127 from robweiss:run_coroutines 56bea93
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
@dbieber
Copy link
Collaborator

dbieber commented Dec 16, 2020

Merged with e4cb72a.

@dbieber dbieber closed this Dec 16, 2020
CherylMoonba added a commit to CherylMoonba/devices that referenced this pull request Jul 20, 2025
COPYBARA_INTEGRATE_REVIEW=google/python-fire#127 from robweiss:run_coroutines 56bea93ea0340bea962a111bbd20122c1ad4beff
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
KurtMuelle added a commit to KurtMuelle/obtained that referenced this pull request Jul 22, 2025
COPYBARA_INTEGRATE_REVIEW=google/python-fire#127 from robweiss:run_coroutines 56bea93ea0340bea962a111bbd20122c1ad4beff
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
hwlegends pushed a commit to hwlegends/python-fire that referenced this pull request Aug 20, 2025
COPYBARA_INTEGRATE_REVIEW=google/python-fire#127 from robweiss:run_coroutines 56bea93ea0340bea962a111bbd20122c1ad4beff
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
marsMerge2021 added a commit to marsMerge2021/NTPMeasures that referenced this pull request Aug 31, 2025
COPYBARA_INTEGRATE_REVIEW=google/python-fire#127 from robweiss:run_coroutines 56bea93ea0340bea962a111bbd20122c1ad4beff
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
Hernandez19891 added a commit to Hernandez19891/Illumina that referenced this pull request Sep 15, 2025
COPYBARA_INTEGRATE_REVIEW=google/python-fire#127 from robweiss:run_coroutines 56bea93ea0340bea962a111bbd20122c1ad4beff
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
1278827 added a commit to 1278827/Hardware that referenced this pull request Sep 23, 2025
COPYBARA_INTEGRATE_REVIEW=google/python-fire#127 from robweiss:run_coroutines 56bea93ea0340bea962a111bbd20122c1ad4beff
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
VLLanguage added a commit to VLLanguage/VLLanguage that referenced this pull request Nov 23, 2025
COPYBARA_INTEGRATE_REVIEW=google/python-fire#127 from robweiss:run_coroutines 56bea93ea0340bea962a111bbd20122c1ad4beff
PiperOrigin-RevId: 347872801
Change-Id: I17407ac8c3cb7b29026bd7d78729747a3a9875cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Author has signed CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants