matt-kimball / mtr-packet-python

Asynchronous network probes for Python
Other
46 stars 6 forks source link

Modernizing `asyncio` usage in examples #4

Open goodboy opened 1 year ago

goodboy commented 1 year ago

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

For example making changes like:


Super dope lib btw 😎

Lookin forward to using it in a serious project 🏄🏼

goodboy commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

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

matt-kimball commented 1 year ago

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.