#python asyncio & #NetDevOps thread
Interaction with network devices is a perfect use-case for Python asyncio - a typical application waits for i/o responses from many devices. Asyncio was designed to focus on i/o heavy apps. It's efficient and enables capabilities, like
1/
...storing all connections to network devices in memory, periodically refreshing them and allows for many tasks to be executed even without a task queue (like celery), simplifying system architecture.
E.g. I can build live network diagrams in the browser within 2 seconds
2/
2 years ago there was a problem with asyncio ecosystem for network automation, but it isn't the case anymore. We have libraries like httpx, scrapli, scrapli-netconf, FastAPI which can be used with asyncio.
I have been using python asyncio for 95%+ my apps during the last year
3/
...I had great experience and I will keep using it for network automation.
It does require some understanding and practice, but imo, it's worth it and I can definitely recommend spending time to learn it. It will allow you to build scalable network automation apps
4/
Get started:
- @TalkPython course: https://training.talkpython.fm/courses/explore_async_python/async-in-python-with-threading-and-multiprocessing
- asyncio docs: https://docs.python.org/3/library/asyncio.html
- tutorials from listed libraries, e.g. FastAPI: https://fastapi.tiangolo.com/tutorial/ 
- @llanga asyncio series:
- ( #netdevops specific) examples on my YT and GH
5/5
You can follow @dmfigol.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.