Async Python Tutorial: Web Scraping Synchronously versus Asynchronously (10x faster)

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 15

  • @suryajithnair8323
    @suryajithnair8323 3 года назад

    Thanks sir, I have been checking about this asynchronous way of programming for some days now but couldn't understand, i have reffered many videos from youtube but none of them is clearly explaining your video really helped me in understanding. Your content's really good wishing you all success.

  • @slava8770
    @slava8770 4 года назад +2

    Write file is locking operation. You should use async library for that.

  • @hideodaikoku
    @hideodaikoku 4 года назад +2

    This video was super helpful and helped save my project a lot of time in development!! Thank you :)

  • @optimiserlenergie1094
    @optimiserlenergie1094 4 года назад +2

    Why not using Aiofile to have the write function async ?

  • @Sra4825
    @Sra4825 5 лет назад +2

    That's an insane speed boost. Thanks a lot for these tutorials. They are very helpful. and completely out of the box, perf_counter() was an unexpected bonus, that I'll be using from here on out. Keep up the good work.

    • @AntonioAndrade
      @AntonioAndrade 5 лет назад +1

      I love this channel and like the good community around here and Python

  • @andrewarderne1567
    @andrewarderne1567 4 года назад +2

    Why is the write_file function async? It looks like the content of the function are synchronous unless I'm not understanding something?
    Would it make a difference if it was just:
    def write_file(n, content): #

    • @ionutthedog8804
      @ionutthedog8804 4 года назад +1

      correct, write_file will always execute in a synchronous manner , but declaring it a as coroutine ,it can be used in await statemens so that the awaiting function always waits for the file to be written before proceeding further. In terms of speed it is as you say . the speed improvement here comes from the fact that aiohttp is built to handle requests asynchronously . Awaiting to get an async http aiohttp response works faster because the call yield to another request that s ready to go

  • @steelday
    @steelday 5 лет назад

    The write file function must be execute using: loop.run_in_executor since write in a file is not handled by the io multiplexer

  • @zanityplays
    @zanityplays 4 года назад +4

    Constructing an aiohttp.Clientsession on each call is very expensive.

  • @ak2agent47
    @ak2agent47 5 лет назад

    So... LN28 is the Promise.all counterpart of JavaScript.