mtr-packet-python
mtr-packet-python copied to clipboard
Modernizing `asyncio` usage in examples
Would this be something you'd accept as a PR?
For example making changes like:
- flipping
loop.run_until_complete()toasyncio.run() - using the new taskgroups from 3.11
- swapping
.ensure_future()with the newerasyncio.create_task()where you'd prefer to not use task groups.
Super dope lib btw 😎
Lookin forward to using it in a serious project 🏄🏼
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) 😄
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?
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.
Oh also, fwiw asyncio.create_task() is from 3.7+
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.