ASYNC file I/O in Python

Поделиться
HTML-код
  • Опубликовано: 29 авг 2024
  • Need to read and write files in your async application? Aiofiles is exactly what you’re looking for.
    -
    If you enjoy my content, consider supporting me on Patreon or becoming a member!
    patreon.carber...
    join.carberra.xyz
    If you need help with anything, feel free to join the Discord server:
    discord.carber...
    I get a lot of people asking, so here's my Visual Studio Code setup!
    • My Visual Studio Code ...
    -
    If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so.
    #python #coding #shorts

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

  • @Indently
    @Indently 7 месяцев назад

    I love the auto-generated captions!
    "aero-files"
    "AOL-files"

  • @songokussj4cz
    @songokussj4cz Год назад

    Just a dumb question. But what are the benefits? Am I understanding this right that when I write to this file a few GB data the program continues it's run and will not hang until the data is written? And what if I need to write into the file from another function but the file is still written to?

    • @Carberra
      @Carberra  Год назад

      1) Pretty much right. It's basically so you don't block async applications. 2) You'd need to handle that yourself.

    • @mr.vladislav5746
      @mr.vladislav5746 Год назад

      @@Carberra What? Doesn't the await keyword make it wait anyway, so the program *doesn't* continue execution? Or did I misunderstand async. Isn't this only beneficial if we read/write many files at once, and then await them all at the same time?

    • @Carberra
      @Carberra  Год назад +2

      You've misunderstood, though the terminology is a bit odd with the whole "await" thing. I did a video a little while that better explains async (ruclips.net/video/vLbZUVKFVxY/видео.html). Aiofiles specifically is probably most beneficial in something like a bot, or some other service that's running 24/7.

  • @eduardmart1237
    @eduardmart1237 10 месяцев назад

    Btw what is the best way to use postgres asynchronously?

    • @Carberra
      @Carberra  10 месяцев назад +1

      Asyncpg is your best bet I believe.