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

Modernizing asyncio usage in examples #4

Open
goodboy opened this issue Aug 10, 2023 · 5 comments
Open

Modernizing asyncio usage in examples #4

goodboy opened this issue Aug 10, 2023 · 5 comments

Comments

@goodboy
Copy link

goodboy commented Aug 10, 2023

Would this be something you'd accept as a PR?

For example making changes like:

  • flipping loop.run_until_complete() to asyncio.run()
  • using the new taskgroups from 3.11
  • swapping .ensure_future() with the newer asyncio.create_task() where you'd prefer to not use task groups.

Super dope lib btw 😎

Lookin forward to using it in a serious project 🏄🏼

@goodboy
Copy link
Author

goodboy commented Aug 10, 2023

Ah and just to justify this request, for our use case we will be deploying the probe tasks as part of existing mostly trio oriented runtime stack which demands end2end structurred concurrency (SC) 😄

@matt-kimball
Copy link
Owner

I'd prefer to keep everything compatible with other compatible with older versions of Python, unless there is some compelling reason to do otherwise. I explicitly wrote the code to be compatible as far back as Python 3.5.

I don't really understand the implications of your second comment. Is there some reason that this module is unsuitable for your purposes as-is?

@goodboy
Copy link
Author

goodboy commented Aug 10, 2023

I don't really understand the implications of your second comment. Is there some reason that this module is unsuitable for your purposes as-is?

Not particularly, but it could be more compatible by leveraging the task groups in terms of errors due to connectivity failures; error bubbling is easier to capture when SC constraints are in place.
It's more like the style would be more compatible and would require less workarounds in our client code.

FWIW i'm only proposing changing come examples, we could even just have a 3.11+ version of the particular use we have.

I explicitly wrote the code to be compatible as far back as Python 3.5.

👍🏼 totally get it.

@goodboy
Copy link
Author

goodboy commented Aug 10, 2023

Oh also, fwiw asyncio.create_task() is from 3.7+

screenshot-2023-08-10_12-45-00

@matt-kimball
Copy link
Owner

If you want to open a PR adding a new example in the style you think is best for modern Python usage, that seems reasonable. I'd like to keep the existing ones compatible with Python 3.5.

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

No branches or pull requests

2 participants