Next-Level Concurrent Programming In Python With Asyncio

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 มิ.ย. 2024
  • If your software interacts with external APIs, you need to know concurrent programming. I show you how it works in Python and then take it to the next level by showing advanced concurrent features such as using async with generators and comprehensions, show a simple way to turn blocking code into concurrent code, and then I cover how concurrency affects software design and architecture.
    The code I worked on in this episode is available here: github.com/ArjanCodes/2022-as....
    💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.
    💻 ArjanCodes Blog: www.arjancodes.com/blog
    🎓 Courses:
    The Software Designer Mindset: www.arjancodes.com/mindset
    The Software Designer Mindset Team Packages: www.arjancodes.com/sas
    The Software Architect Mindset: Pre-register now! www.arjancodes.com/architect
    Next Level Python: Become a Python Expert: www.arjancodes.com/next-level...
    The 30-Day Design Challenge: www.arjancodes.com/30ddc
    🛒 GEAR & RECOMMENDED BOOKS: kit.co/arjancodes.
    👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
    💬 Discord: discord.arjan.codes
    🐦Twitter: / arjancodes
    🌍LinkedIn: / arjancodes
    🕵Facebook: / arjancodes
    👀 Code reviewers:
    - Yoriz
    - Ryan Laursen
    - James Dooley
    - Dale Hagglund
    🎥 Video edited by Mark Bacskai: / bacskaimark
    🔖 Chapters:
    0:00 Intro
    1:10 Concurrency vs parallelism
    2:33 The Global Interpreter Lock
    3:06 The benefits of concurrency
    4:36 Recap of asyncio in Python
    7:13 Using gather to send out multiple requests
    9:44 How async and await are integrated into Python's syntax
    11:54 Turn blocking code into concurrent code
    16:04 Async http requests
    16:53 Aiohttp
    17:50 Concurrency, design patterns, and architecture
    #arjancodes #softwaredesign #python
    DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!

ความคิดเห็น • 271

  • @ArjanCodes
    @ArjanCodes  8 หลายเดือนก่อน

    💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.

  • @MrTrebor2
    @MrTrebor2 2 ปีที่แล้ว +178

    Let's go deeper in async. Exceptions handling, pubsub pattern and how to manage back pressure.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +3

      Nothing specific to asyncio there.

    • @josephlangford2912
      @josephlangford2912 ปีที่แล้ว +20

      I'll show you how to handle back pressure

    • @infernape716
      @infernape716 8 หลายเดือนก่อน

      ​@@josephlangford2912💀

    • @jasonmogavero3709
      @jasonmogavero3709 3 หลายเดือนก่อน

      ​@@josephlangford2912 gottem!

  • @BladeAndrade
    @BladeAndrade 2 ปีที่แล้ว +84

    I'd be great to see a series of concurrency/parallelization in python.

  • @arthurguz2672
    @arthurguz2672 2 ปีที่แล้ว +65

    Regarding your criticism about nested contextmanagers (at 17:35)...
    Since Python3.10 you are able to write something like this:
    async with (
    aiohttp.ClientSession() as session,
    session.get(url) as response,
    ):
    return await response.json()
    This is super usefull :)

    • @jeroenvermunt3372
      @jeroenvermunt3372 ปีที่แล้ว +12

      Thanks a lot for this! Why do I have not seen this before.
      Is it just me or is python so much getting so much cleaner as javascript for these types of thing (I'm a beginner at javascript so totally biased, I think it looks ridiculous)

    • @kosmonautofficial296
      @kosmonautofficial296 ปีที่แล้ว +1

      woah cool!

    • @user-hn6cc2tg2j
      @user-hn6cc2tg2j ปีที่แล้ว +1

      Thanks a lot for this

    • @shivampundir1829
      @shivampundir1829 ปีที่แล้ว +2

      With python 3.11 we can now use Taskgroups as well.

    • @AhriaHasegawa
      @AhriaHasegawa 11 หลายเดือนก่อน +1

      What! This is so cool! Thank you for this!

  • @cetilly
    @cetilly 8 หลายเดือนก่อน +1

    Love, love, love your presentation style; so systematic, well thought out, and articulate.

  • @sval4020
    @sval4020 2 ปีที่แล้ว +7

    Very helpful video, Arjan! Exactly what I was looking for! I will be looking forward to even more asyncio videos from you! Thank you!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว +1

      Glad to hear it was helpful!

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 2 ปีที่แล้ว +29

    15:13 You could leave out both the “await” and the “async”. So “send‗async‗request” becomes a regular function which returns an awaitable.

  • @varswe
    @varswe 8 หลายเดือนก่อน +2

    Best video on async, finally someone who shows why , when and how to use async. Cleared all my doubts, Thank you

  • @MrJjthecronfan
    @MrJjthecronfan ปีที่แล้ว

    Thanks so much - Learning a lot from here . A friend of mine recommended your channel , now I am passing it on to others . Good Luck

  • @seeds_of_growth-yi5gx
    @seeds_of_growth-yi5gx ปีที่แล้ว

    I really like the practical approach of exploring the topic, it's my favorite way of learning things. Keep going!
    just subscribed and signed up for the diagnosis course, eager to start and jump to the next ones. Thanks for sharing

  • @sudadal-ajili6205
    @sudadal-ajili6205 2 ปีที่แล้ว +1

    Hey Arjan! Thank you for such amazing contents I have learned a lot from your videos. It will be great to see videos about Threading and Multiprocessing.
    Thank you again.

  • @CaptainCsaba
    @CaptainCsaba 2 ปีที่แล้ว +1

    I can't count the amount of times I've tried to find the best method for asnyc requests. I've used aiohttp just like you but it never felt right, but I never understood asyncio enough so this was always something I was scared of more than I should have. I am so happy that you have actually shown the best way to do it, it will help a lot in my everyday work!

  • @tobilobaogunware6686
    @tobilobaogunware6686 2 ปีที่แล้ว +1

    Hi Arjan, your videos have been of really great help to me. If possible, a video about using the Aiohttp module with asyncio would be really nice. Fingers crossed. Thank you for all you do!

  • @simmonslucas
    @simmonslucas ปีที่แล้ว +8

    I would love more examples using queues and event loops

  • @leoff2
    @leoff2 2 ปีที่แล้ว +9

    you didn't mention the difference between using `requests` + `to_thread`, and `aiohttp`. Although `aiohttp` is more verbose, it is faster since it involves no threads. You can also reduce indentation by creating the session beforehand and reusing it.

  • @getpoked101
    @getpoked101 2 ปีที่แล้ว

    Great video. We are doing a bunch of data ingestion from a rest api right now so this is very top of the mind.

  • @aashayamballi
    @aashayamballi ปีที่แล้ว

    Loving it! Thanks Arjan.. this video was very informative, would like to see more videos on async python 🙏

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว +1

      Thank you, glad you liked it! I’ll surely revisit async in the future.

  • @Whatthetrash
    @Whatthetrash ปีที่แล้ว

    Thanks so much! Love to see your videos. Thanks so much for making and sharing them! ^_^

  • @EekaMau5
    @EekaMau5 ปีที่แล้ว

    Thank you ! this tutorial was awesome !

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Glad you liked it!!

  • @arturkabitcher
    @arturkabitcher 2 ปีที่แล้ว +4

    Arjan, I really like your videos. Could you please make more content on async Python? This content (unlike many other topics) is barely covered on TH-cam, so you'll be guaranteed to have lots of views and we'll be guaranteed to have a more deep understanding of that complex topic.
    Multiprocessing and multithreading topics are also highly anticipated.

  • @valentinasinichenko751
    @valentinasinichenko751 ปีที่แล้ว

    this has been extremely helpful

  • @michtesar
    @michtesar 2 ปีที่แล้ว

    That is very useful and interesting video discussing asyncio library. I was about to read the docs, but now I think I don't have to, thanks to your video! Great content! Thanks for that!

  • @walis85300
    @walis85300 2 ปีที่แล้ว

    Thanks for improving the way the video looks

  • @AMMullan
    @AMMullan 8 หลายเดือนก่อน

    Amazing video and so well explained! I’ve been trying to get a better understanding of how to use asyncio and it’s not easy but you’ve done an incredible job. Will definitely be checking out your other videos. Thanks man!!!

    • @ArjanCodes
      @ArjanCodes  8 หลายเดือนก่อน

      I'm really glad it was helpful! Welcome to the channel :)

  • @djl3009
    @djl3009 ปีที่แล้ว

    Nice one. Thanks!

  • @guplex
    @guplex 2 ปีที่แล้ว

    Thanks! Would love more asyncio content

  • @tharo20
    @tharo20 11 หลายเดือนก่อน

    This video helped me a lot! thank you so much!💌

  • @psadi_
    @psadi_ 2 ปีที่แล้ว

    Very useful, thanks 🙏🏼

  • @julienstanguennec9563
    @julienstanguennec9563 ปีที่แล้ว +2

    Another video on parallel programming could be very nice ! Thanks for all the material you provide, it's really helpful.

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว +1

      Thanks so much, Julien, glad the content is helpful!

  • @nateriver8261
    @nateriver8261 2 ปีที่แล้ว

    Very helpful video, Arjan!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thanks Nate, glad it was helpful!

  • @eldarmammadov7872
    @eldarmammadov7872 ปีที่แล้ว

    great explanation with giving right examples

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว +1

      Glad you liked it, Eldar!

  • @BlackCloudsAC
    @BlackCloudsAC 2 ปีที่แล้ว +9

    Hey Arjan, thanks for posting this! You've opened my eyes to asyncio.
    I was wondering if you could explain when you'd use async methods vs when you would use Multi Threading through a ThreadPool?
    Many thanks!

  • @kahvelikod6377
    @kahvelikod6377 2 ปีที่แล้ว

    Very useful , Thank you.

  • @huonglarne
    @huonglarne ปีที่แล้ว

    this is incredibly helpful. Thank you so much

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thanks so much, Mo Gung, glad the content is helpful!

  • @FEchtyy
    @FEchtyy ปีที่แล้ว

    so helpfull! thanks a lot

  • @riptorforever2
    @riptorforever2 ปีที่แล้ว

    Great lesson. Thanks

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thank you, glad you liked the video!

  • @mentefria98
    @mentefria98 ปีที่แล้ว +1

    this was so hepful, thanks.

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว +1

      Thanks so much, glad the content is helpful!

  • @thghtfl
    @thghtfl 8 หลายเดือนก่อน

    Thank you so much, man! Brilliant explanation!

    • @ArjanCodes
      @ArjanCodes  8 หลายเดือนก่อน

      I'm glad it helped!

  • @VictorNedilko
    @VictorNedilko 11 หลายเดือนก่อน

    Great tutorial and fantastic way of presenting.
    Thanks

    • @ArjanCodes
      @ArjanCodes  11 หลายเดือนก่อน

      Thank you!

  • @dmytrokorbanytskyi1586
    @dmytrokorbanytskyi1586 2 ปีที่แล้ว

    Thanks for the video! I really like your coding style )

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thank you - glad you like the video!

  • @holographicsol2747
    @holographicsol2747 ปีที่แล้ว

    really helpful thanks man

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว +1

      Glad to hear it!

  • @robertmielewczyk4219
    @robertmielewczyk4219 2 ปีที่แล้ว +1

    It would be great to see a video about exception handling with asyncio, and forever running tasks using asyncio.

  • @k98killer
    @k98killer ปีที่แล้ว +1

    Comment before watching the full video: I wrote my first bit of code using asyncio (an example implementation of a library I've built) just a few days ago after watching your previous videos on asyncio. Very cool. Building an interactive CLI tool that runs a networking application in the background has been on my to-do list for a long time, so I'm quite happy I figured it out.
    On a separate topic, have you considered making a video on publishing python packages to PyPI?

  • @assaidy
    @assaidy 23 วันที่ผ่านมา

    you provide really good examples in your tutorials. Amazing channel.

    • @ArjanCodes
      @ArjanCodes  22 วันที่ผ่านมา

      Thank you so much! Glad you like the content.

  • @draufunddran
    @draufunddran 2 ปีที่แล้ว +1

    I would like to have more videos about concurrency and asynchronous stuff... Please don't wait too long for the video about this topic.

  • @mlenox
    @mlenox 2 ปีที่แล้ว

    Excellent!

  • @JohnMatthew1
    @JohnMatthew1 2 ปีที่แล้ว +1

    As always, I always learn something from your videos, THANK YOU. The to_thread() is new to me, very cool
    Too much sun? Nice color.

  • @anandptyagi5275
    @anandptyagi5275 ปีที่แล้ว

    Hello, Thank you for the information. I like your way of teaching, and I would like to see more advanced topics in python explained by you, If possible please do. Have a good day, thanks.

  • @ATXAdventure
    @ATXAdventure 11 หลายเดือนก่อน

    I always check out Arjan when I need to brush up on ways to accomplish things in python.

  • @DeepakYadav-ic2uv
    @DeepakYadav-ic2uv ปีที่แล้ว

    this was helpful!

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thanks so much Deepak, glad the content is helpful!

  • @HIMixoid
    @HIMixoid 2 ปีที่แล้ว +1

    Great! I hope more videos about asyncio are coming ^___^

  • @david14panik
    @david14panik 2 ปีที่แล้ว

    What a coincidence... I was dealing with this packages (asyncio & aiohttp) and you published this video today, lol.... Now I understand some things I actually really need to improve performance.
    Only 2 things I have to say:
    - I've read aiohttp is faster than requests but readable.
    - Request performance drops quite a bit when cookies are used and I'm not sure why. (ClientSession(cookies=mycookies))
    👍🍺 Great video mate

  • @kunvensoong6047
    @kunvensoong6047 2 ปีที่แล้ว +2

    Great video! Looking forward for a video that refactors sync+unittest to async+unittest

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thank you, glad you liked it!

  • @71sephiroth
    @71sephiroth 5 หลายเดือนก่อน

    Pfff... nobody knows the struggle of getting Mewtwo on the first try. ;) Thanks for the comprehensive introduction!

  • @AnhNguyen-ze4vm
    @AnhNguyen-ze4vm ปีที่แล้ว

    Thanks for your really useful video. Can you do another video on specifying which part of the program to run concurrently and sequentially?

  • @user-mi2bb8bm6s
    @user-mi2bb8bm6s 9 หลายเดือนก่อน

    Thank you for very helpful video.
    Mewtwo is one of legendary poketmon, but you got it with just two choices!

  • @barrakabot6001
    @barrakabot6001 2 ปีที่แล้ว

    Great Stuff

  • @CharleswoodSpudzyofficial
    @CharleswoodSpudzyofficial ปีที่แล้ว

    Woah... I'm blown away. Another new level for my Python code career

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thanks so much Charles, glad the content is helpful!

  • @re.liable
    @re.liable ปีที่แล้ว

    That type union is dope :O
    Haven't coded in Python for a while; been trying to get into JS frameworks. I love that union type :D

  • @sebastianzander87
    @sebastianzander87 2 หลายเดือนก่อน

    Since you said that you "don't like these nested 'with' statements" 17:36, I remember there is a Python feature probably not so well known: you can declare multiple variables in one 'with' statement by delimiting them by commas 🙂

  • @JordanBonnett
    @JordanBonnett ปีที่แล้ว

    All other videos and tutorials I saw show the same example with asyncio.sleep()... Thanks for create a custom example a explain very well this tricky subject of python asynchronous programming. +100

  • @fartzy
    @fartzy 2 ปีที่แล้ว +1

    I think one way to say it - to say parallelism vs concurrency - is to say the system parallelizes. However, the system handles concurrency. The system chooses to parallelize. The system reacts to concurrency.

  • @christerpherhunter930
    @christerpherhunter930 2 ปีที่แล้ว

    This is helpful to me.

  • @demolazer
    @demolazer 4 หลายเดือนก่อน

    Just what I needed. I've got an app making a bunch of one by one API and SSH calls to my server which takes forever right now.

    • @ArjanCodes
      @ArjanCodes  4 หลายเดือนก่อน

      I'm glad the video was helpful!

  • @Artur-hn8sg
    @Artur-hn8sg 2 ปีที่แล้ว

    Simple brilliant)😎👍

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thank you, glad you liked it!

  • @mahdiasadnejad3804
    @mahdiasadnejad3804 2 ปีที่แล้ว

    Thank you, it was great . let's go deeper!

  • @MujtabaMuhammadKhushtaba
    @MujtabaMuhammadKhushtaba ปีที่แล้ว

    awesome video, looking forward to new videos

  • @user-fo7nz2mr1o
    @user-fo7nz2mr1o ปีที่แล้ว

    Thanks!

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thank you so much, Екатерина! I appreciate your support!

  • @Hubert4515
    @Hubert4515 2 ปีที่แล้ว +1

    cool as always :)

  • @hrvojetonkovac6519
    @hrvojetonkovac6519 ปีที่แล้ว

    Thanks

  • @burakcelik3752
    @burakcelik3752 2 ปีที่แล้ว

    TL;DR # Excellent, thank you for the great content.#
    I really appreciate your work as thinking how much time you spent to create high quality contents like this. I watched a lot of videos when I started coding but %90 of them was like demonstrating an isolated feature of Python using a Jupyter Notebook. I accept that I learned so much things from them but here was the problem. Even if I learned so much deep, for instance using generators as coroutines that is what basically what asyncio implements now, but I'd never managed to get that advanced techniques together I later realize that was because I learned all the things in isolation and would stuck when it comes to use them all together, that is, the links were missing. Arjan, you did a great job starting to talk about design patterns that I realized the missing links were not the techniques but the philosophy. Therefore I can't recommend your channel enough for people who stuck in the intermediate level of coding and don't know why can't take a step further regardless of whatever new things they learn. I know there must full of people in that situation and think a great deal of them gives up in the end. Your channel is just a treasure for the people in subject and must be spread. As for concurrency, I've always found using preemptive multitasking far from being elegant because it inherently is a brute force approach and I can't imagine anybody who don't love asyncio s/he learns the philosophy behind it. Since we don't have too many options for cpu bound problems because of GIL even if we tackle the problem by splitting it independent sub methods, we can do much for IO bound problems using asyncio and I would appreciate if you consider to continue on the subject. For instance, how can we develop our own cooperative multitasked classes aside from using the external ones (except sending the couroutines to threads). For instance, think a project that used requests-http for its internal processes but doesn't explicitly support asyncio for its public methods. It's obvious that it has capacity for doing that and we can branch and give it our own asyncio support with a little effort and it would be great to learn how an async class should be designed philosophically. The last word is thank you for your great channel and efforts again.

  • @cristeapaul5634
    @cristeapaul5634 ปีที่แล้ว

    Thank you so much for the video it was very helpful for me!
    I have one question regarding that handy JSON variables.
    Where should I keep some kind of typing variable in a bigger project?

  • @Obi-Wan-Kenobii
    @Obi-Wan-Kenobii 2 ปีที่แล้ว

    Thanks for covering async.. I have once written an aiohttp based webservice to retrieve data from neo4j.. Aiohttp github page have some nice async libraries collections.. I hope more developers will release async libraries as well..

  • @dewciu4904
    @dewciu4904 2 ปีที่แล้ว

    Thank you for your movies! You make me better python developer :)

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      You’re welcome - glad you like them!

  • @experimentalhypothesis1137
    @experimentalhypothesis1137 9 หลายเดือนก่อน

    more async videos please, lets go deeper with u - u can explain this stuff very well

    • @ArjanCodes
      @ArjanCodes  9 หลายเดือนก่อน

      Noted! Thanks ;)

  • @sugo8920
    @sugo8920 ปีที่แล้ว +1

    I'm in love with async python now. Almost all apps will use other services. Almost everything uses REST now. This greatly speeds up by code and it more fun than sync programming.
    I recommend integrating your applications with Datadog if you can with APM enabled. Very satisfying to see parallel traces and great for optimizations as it can be used to uncover things that one may have thought were running in parallel but were not.
    Last is, to_thread is not a complete substitute for using aiohttp. Threads will start up slighly slower and I noticed that only 8 threads were running at one time when I used, where as if I used aiohttp everything ran at the exact same time and I was was able to run 100s of request in parallel were as with to_thread I was limited. Perhaps there is some env var i could have set to prevent the 8 thread limit but I could not find any docs on the topic.

  • @martinndegwa7155
    @martinndegwa7155 10 หลายเดือนก่อน

    awesome video

  • @NostraDavid2
    @NostraDavid2 2 ปีที่แล้ว

    I hope one of your future videos goes into what the async keyword actually does with your code.
    Sure, I know that *now*, as I worked with async before out of necessity (which was a great learner for me), but before that I was completely befuddled on what that keyword does and why it made my code stop running unless I used something like async.gather().

  • @kevon217
    @kevon217 11 หลายเดือนก่อน

    I’m just starting to get into async. Have you thought about doing a tutorial on async use in the context of LLM calls and frameworks?

  • @iloveraplot
    @iloveraplot 2 ปีที่แล้ว

    Greate quality of videos.
    Could Async be used on Class bassed views in Django, and how?

  • @goodnewsjohn2482
    @goodnewsjohn2482 ปีที่แล้ว

    really nice video. please can you do something with celery and gevent

  • @Theeoldmann
    @Theeoldmann ปีที่แล้ว

    IDK how or why, but the subject matter of your videos seem to show up (TH-cam suggestion page) exactly when I need a bit more understanding of what I'm actually working with at the time. The providence is well received and please keep making great videos. Thank you

  • @imsjpinternal9554
    @imsjpinternal9554 ปีที่แล้ว

    thanks for great videos! i have question, do you think we can have multiple ssh connection at same time, for example connecting to 20 hosts and executing same cmd at same time for each host. thank you

  • @EricNeilson_
    @EricNeilson_ ปีที่แล้ว

    When you introduce aiohttp and describe the differences, this is hilarious. For a relatively noob like me, it's a lot to digest :) But it's great.

  • @tiktuktiktuk
    @tiktuktiktuk 2 ปีที่แล้ว

    Would like to see more on async..

  • @TheEmrobe
    @TheEmrobe ปีที่แล้ว

    Awesome tutorial and all, but what really blew my mind was the existence of a Pokemon-API :D

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      I know! After discovering that, my life is complete.

  • @HarshMittalYoutube
    @HarshMittalYoutube ปีที่แล้ว

    Great Tutorial. Just wondering what will be the best alternative for to_thread for Python 3.8 and lower as to_thread is only available in Python 3.9+ ? Is using gather the only option?

  • @EnglishRain
    @EnglishRain ปีที่แล้ว

    What an excellent explanation! Subscribed!

  • @LittleCrazy2life
    @LittleCrazy2life 2 ปีที่แล้ว +2

    if possible make a video on writing test cases on async functions!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว +3

      Thanks for the suggestion!

  • @ujjawalsinha8968
    @ujjawalsinha8968 2 ปีที่แล้ว

    What do you think about Prefect for task management, especially Prefect 2.0?

  • @bmilreu
    @bmilreu 2 ปีที่แล้ว

    Great video as always. I also don't love the nested context managers but in aiohttp's case if you're doing more than a single HTTP request to the same server reusing the ClientSession saves significant time on subsequent requests.
    Do you have any thoughts on Structured concurrency as a better alternative to async programming? After trying AnyIO/Trio lately I realized how messy it is to handle errors/cancelling properly on asyncio. It's also a bit too easy to write code that looks correct but isn't, and you will only realize that too late when you scale and out of nowhere there's data races and deadlocks.
    Python 3.11 should bring TaskGroups and Exception Groups which are two of the most important features of structured concurrency, but ofc asyncio will still allow you to shoot yourself in the foot with parentless tasks and unsafe resource handling.

  • @radomirmijovic2605
    @radomirmijovic2605 ปีที่แล้ว

    Hi Arjan i really like you tutorials. Is it possible for you to make a video about getattr() method?

  • @vigneshmurali1994
    @vigneshmurali1994 ปีที่แล้ว

    What is the shortcut you are using to get into insert mode ( Block Cursor). It would be helpful if you could do a VS Code quicktour

  • @jochinq3116
    @jochinq3116 ปีที่แล้ว

    Awesome, thanks for this video! maybe you would like to make a video about asyncio and websocket?🤩

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thank you, for suggestion, I have put it in my list.

  • @MrEloska
    @MrEloska ปีที่แล้ว

    Could you make some advanced video on GIL? Where you can explain how it works, how to "bypass" it etc?

  • @PaulSebastianM
    @PaulSebastianM 2 ปีที่แล้ว

    Concurrency and Parallelism are two steps towards multi-threading (green or not).
    Concurrency is the first step, and means being able to define and start more than one function at a time without waiting for a return value at the call site.
    The two functions can run in series or in parallel, on one shared thread or two separate threads, it all depends on the system and hardware and load. They also run in the same process that started them.
    Parallelism is the second step, it is Concurrency but with an explicit request to try and run truly in parallel, by explicitly using an operating system thread for each function call. But it actually does not imply that the functions will truly run at the same time. It's up to the system to schedule and run these threads, which could be in parallel or in series if there is too much load on the system.

  • @rafalsikora3030
    @rafalsikora3030 ปีที่แล้ว

    great video! maybe can you make "next-level threaded concurrent programming" that will run async WebSockets on all CPUs?

  • @jorgev4656
    @jorgev4656 ปีที่แล้ว +1

    hi. whats the difference between multiprocesing, and asyncio ?

  • @Krzako
    @Krzako ปีที่แล้ว

    Just one thing. You compare sync version with print in loop vs async with just one print. Of course it doesn't change the fact that async is much faster but to get more accurate results we have to remember to measure functions without unwanted code like slow prints ;-)
    Anyway great video. I'm mid developer that switched to python from other scripting language. I recently found your channel and liked it very much. I'm learning a lot from you. Thank you for all your great work!

  • @Tout-Le-Monde02
    @Tout-Le-Monde02 ปีที่แล้ว

    So I can also use the to_thread method to async call multiple object detection model method? Each method takes close to 5 seconds to execute, so for 5 input images instead of doing it sequentially and taking 25 seconds, it should do the job parallelly much faster?