Hynek Schlawack
Hynek Schlawack
  • Видео 10
  • Просмотров 55 630
Master Flaky Systems With Retries in Python 🐍 (avoid self-DDoS)
Every system fails eventually and your Python app is no different. And while failure is inevitable, downtime isn't. One of the key reliability tools in distributed systems are retries - so let's look how they can do more harm than good, and how to retry safely and easily in Python by using the stamina and httpx packages as examples. Both using a decorator and a smart loop-context manager combo!
🔗 Links
► stamina.hynek.me/
► tenacity.readthedocs.io/
► www.structlog.org/
► en.wikipedia.org/wiki/Thundering_herd_problem
► en.wikipedia.org/wiki/Denial-of-service_attack#Distributed_DoS
► www.bbc.com/news/business-64652835
► www.w3.org/Provider/Style/URI
► sre.google/books/
► how.complexsystems.fail
► en.w...
Просмотров: 1 188

Видео

uv IS the Future of Python Packaging! 🐍📦
Просмотров 32 тыс.2 месяца назад
It's been six months since I asked whether #uv is the future of #Python packaging: ruclips.net/video/_FdjW47Au30/видео.html With uv 0.3.0, the answer is IN and I'll tell you WHY, and WHAT’s missing to be the PRESENT of Python packaging. 🔗 Links ► Astral’s 0.3.0 announcement: astral.sh/blog/uv-unified-python-packaging ► Documentation for the new projects feature: docs.astral.sh/uv/concepts/proje...
NOX vs TOX - What are they for & how do you choose? 🐍📦
Просмотров 2,8 тыс.7 месяцев назад
If you need to test Python packages or applications across multiple test environments you need tox or Nox. In this video I explain the problems they solve, the differences between them, and how I choose for my projects with over 300 millions of monthly downloads. 🔗 Links ► tox.wiki/ ► nox.thea.codes/ ► ruclips.net/video/_FdjW47Au30/видео.html ► Two Ways to Turbo-Charge tox: hynek.me/articles/tu...
Is UV the FUTURE of Python PACKAGING? 🐍📦
Просмотров 10 тыс.9 месяцев назад
Six months later, the answer is in: ruclips.net/video/8UuW8o4bHbw/видео.html Astral’s uv burst without a warning into the Python scene and made a huge impression! How does it fare in the context of Python's packaging problems… and what ARE those problems in the first place?! 🔗 Links ► Cross-Platform Lockfiles are coming (hopefully): discuss.python.org/t/lock-files-again-but-this-time-w-sdists/4...
Loose Coupling & Dependency Injection the EASY Way! 🐍
Просмотров 3,8 тыс.10 месяцев назад
This is a pragmatic approach to loose coupling and dependency injection with a focus how at they core they’re SIMPLE concepts that improve YOUR life! And: have you heard of dependency LOCATION at all?! We‘ll use simple #Python to demonstrate all that! ► Learn more about my service location package: svcs.hynek.me/ ◀ 🤓 ME ELSEWHERE 🏡: hynek.me/ 🐘: mastodon.social/@hynek/ 🦋: bsky.app/profile/hynek...
svcs: Robust & TESTABLE #Python Web Applications with ANY Framework!
Просмотров 3 тыс.Год назад
This is a quick intro to the svcs package - a flexible service locator for Python! Watch it if you want to improve the handling of your web application's services/dependencies/resources or if you want to learn what any of that means - and whether it's dependency injection! ► Learn more here: svcs.hynek.me/ ◀ ► Want svcs for DJANGO? Check out: github.com/django-svcs/django-svcs ► Love LITESTAR!?...

Комментарии

  • @AbdolaMike
    @AbdolaMike 2 дня назад

    Hynek this looka awesome i'll definitely use stamina in some projects i was already using Tenacity but just setting retries to 3 but your video convinced me i need a little better tuning! appreciate it and love your videos!

  • @RoelAdriaans
    @RoelAdriaans 8 дней назад

    The first time I didn't understand this short, so I retried watching it three times.

    • @The_Hynek
      @The_Hynek 7 дней назад

      Thank you for your dedication! 💛 Maybe try the real video it’s from for extra context. 😇

    • @RoelAdriaans
      @RoelAdriaans 7 дней назад

      @@The_Hynek I watched the original movie 9 times, and now everything is clear 🔎😎 (Should have added a :-) in the first message :D)

    • @The_Hynek
      @The_Hynek 7 дней назад

      Oh god I’m an idiot NOW I got it 😅

    • @nilpatel2795
      @nilpatel2795 6 дней назад

      And I retried 3 times

    • @The_Hynek
      @The_Hynek 6 дней назад

      I hope you guys are being responsible and add appropriate backoffs and jitters!

  • @vinayak254
    @vinayak254 8 дней назад

    very good. i have a doubt, can UV work well with django ??pls let me know

    • @The_Hynek
      @The_Hynek 8 дней назад

      There’s no reason for it to not work with Django. Checkout blog.pecar.me/uv-with-django

    • @vinayak254
      @vinayak254 8 дней назад

      @@The_Hynek thanks for your reply. i will try it out

  • @SFPython
    @SFPython 14 дней назад

    Stamina is great! I love that now I'm getting paged 3 times with jittered, exponential backoff. ;D

    • @The_Hynek
      @The_Hynek 14 дней назад

      Just like with food, there's *good* and *bad* paging!!1!

  • @OasBTW
    @OasBTW 14 дней назад

    I discovered your channel thanks to the "algorithm" and it’s a bliss. I really liked the video on Nox and tox and I’m looking forward to checking out stamina and structlog.

    • @The_Hynek
      @The_Hynek 14 дней назад

      Welcome aboard! 💛 100k more of you and this channel becomes viable! :D

    • @OasBTW
      @OasBTW 13 дней назад

      ⁠@@The_Hynek I wish it does!

  • @kelownatechkid
    @kelownatechkid 16 дней назад

    They have always been responsive in my interactions on GitHub. Charlie seems like a very smart guy. I became an instant user of uv when it took one of my projects' build times from minutes to seconds!

  • @timseguine2
    @timseguine2 16 дней назад

    cool library. will probably use

  • @glyph_official
    @glyph_official 16 дней назад

    If you're concerned about engagement with the youtube algorithm just do an aesthetic desk setup video where you talk about all the python packages you have installed in ~/.local while slow-panning over the logitech MX master, the CalDigit TS4, an ultrawide monitor and a macbook in clamshell mode in a vertical stand. Bonus points if it's *your* desk, but honestly that's probably not necessary

    • @glyph_official
      @glyph_official 16 дней назад

      Or do that distributed retry budgets video. 3 hour runtime easy, super high retention because every way to get it wrong is a cliffhanger

    • @The_Hynek
      @The_Hynek 16 дней назад

      I mean I own some of those things, but I'll need a lot more views to upgrade my TS3 to a TS4 and get a new monitor - like and subscribe everybody!

    • @The_Hynek
      @The_Hynek 16 дней назад

      @@glyph_official i think i'll need to figure out how to switch my LEDs to purple first

  • @rednafi
    @rednafi 16 дней назад

    This is amazing. I like that Stamina has nicer defaults than Tenacity. The type hints are an added bonus. One question: when you say loops can’t handle exceptions, I was wondering what that means. We can use a try...except in loops, can’t we? Could you please point to a resource that explains why the context manager within the iterator helps here?

    • @The_Hynek
      @The_Hynek 16 дней назад

      YOU can use a try-except but the whole point of stamina (and Tenacity) is that we handle the errors automatically for you. I guess we could do something like `try: whatever() except Exception as e: attempt.handle()` but that's no way better than wrapping it into a context manager.

  • @biophysics
    @biophysics 16 дней назад

    "I care a lot about automated testing, because I don't trust myself to write correct code, and if I did by accident, I don't trust myself to not break it in the future." - Hynek 2024 Pure poetry, I love it. ^^

    • @The_Hynek
      @The_Hynek 16 дней назад

      the secret is to know one's limits 🧘‍♂️

  • @squishy-tomato
    @squishy-tomato 16 дней назад

    thank you, Jason Segel of Python

    • @The_Hynek
      @The_Hynek 16 дней назад

      oof man i wish i had his hair ;)

  • @goparism
    @goparism 16 дней назад

    Good stuff. Usually I write a simple basic retry decorator with all the things you've mentioned instead pip installing another library. Not sure if I'll end up using it, but I'll check it out :)

    • @The_Hynek
      @The_Hynek 16 дней назад

      Heh I’ve done it manually before too; the only thing that can get tricky is proper backoff computation. Fortunately there’s boltons with its drop-in-friendly design: boltons.readthedocs.io/en/latest/iterutils.html#boltons.iterutils.backoff_iter (I.e: no installation needed)

  • @Lexaire
    @Lexaire 16 дней назад

    New Hynek video dropped! Love the library, will be trying it out soon!

  • @iplith
    @iplith 16 дней назад

    Great video, thanks !

  • @TwintailNami
    @TwintailNami 25 дней назад

    I still have difficulties understanding if i have to create a venv or not in uv.

    • @The_Hynek
      @The_Hynek 25 дней назад

      uv will do that automatically for you

    • @TwintailNami
      @TwintailNami 25 дней назад

      @ awesome!

  • @marksouthcombe
    @marksouthcombe 27 дней назад

    Great work Hynek, well presented. Thank you

  • @netneutrality2024
    @netneutrality2024 Месяц назад

    Thanks. A very helpful video that gave answers to all my questions. I'm going to replace pyenv and pip-tools with uv.

  • @leomak7580
    @leomak7580 Месяц назад

    Cool channel. Happy to find it. Looking forward for nw vids

    • @The_Hynek
      @The_Hynek Месяц назад

      Thank you; you and I both! 😅

  • @ringpolitiet
    @ringpolitiet Месяц назад

    Love your style! Instant subscribe. And a great video. uv it is from now on.

  • @muhammadaneeqasif572
    @muhammadaneeqasif572 Месяц назад

    can you please comment on uv in systems like nixow

    • @The_Hynek
      @The_Hynek Месяц назад

      sadly I can't, because I've bounced of NixOS many times. However, I've already heard from Nix friends that they plan on creating something like poetry2nix for uv's - and hopefully eventually Python's official - lock file format.

  • @dschonhaut
    @dschonhaut Месяц назад

    Coming from conda…wtf is this video about? I have never been more confused than right now

    • @The_Hynek
      @The_Hynek Месяц назад

      Conda has a very different scope than Python's packaging - it's closer to a Linux distribution than to an ecosystem packaging solution.

  • @timseguine2
    @timseguine2 2 месяца назад

    I have been a python fan since the python 1.5 days (and my previous language experience was pre-standard javascript and pre-standard C++, so I always found it quite impressive), but as great as I have always found it, it has often been hard to be a python fan. The build tooling and package management in a lot of other languages is so much better.

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Which is why it's now time to celebrate! 🥳

  • @davidboreham
    @davidboreham 2 месяца назад

    Imho writing tooling for language A in language B is a very bad smell. I get that Rust is a shiny object but now whoever is using the tool is unlikely to understand how to debug and fix the tool. Conversely those writing the tool don't need to understand the target language.

  • @robfielding8566
    @robfielding8566 2 месяца назад

    does this work with Mojo?

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Sorry, I don’t know anything about Mojo beyond that it exists and that it‘s from Chris Lattner.

  • @pumpichank
    @pumpichank 2 месяца назад

    Fantastic video! I really think you nailed both the technical and human aspects of this sea change in Python packaging. I especially appreciate how you called out all those giant shoulders the Astral folks are standing on. Ruff and uv are amazing tools and they are great partners in helping guide standards to keep interop, multi-culture, and innovation alive.

  • @marcus3d
    @marcus3d 2 месяца назад

    "It automatically installs..." Uh? How? Where? How do I remove crap that some random uv thing automatically installed? How can I see what has been automatically installed? How does the automatically installed things integrate with proper system packages (say, on a debian-based distro)?

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Where: `uv python dir` How to prevent: `UV_PYTHON_DOWNLOADS=never ` How does it integrate: it doesn't, that's the whole point. People have been begging for a decoupling forever. If you don't want that, the the env variable or pass `--no-python-downloads`. I set the variable in all my Docker base images.

    • @pradyunsg
      @pradyunsg 2 месяца назад

      There's also configuration files at a project, user and (soon!) system level where you can configure this too.

  • @andrew.derevo
    @andrew.derevo 2 месяца назад

    good stuff ❤

  • @ZarifAziz
    @ZarifAziz 2 месяца назад

    wish there was a comparison done with poetry here

    • @The_Hynek
      @The_Hynek 2 месяца назад

      I'm trying my best to follow the rough rule that I don't speak ill of other people's projects which has the unfortunate but inevitable consequence that I'll never speak about Poetry.

  • @enno1162
    @enno1162 2 месяца назад

    Pip is not replacaeable by uv pip. Order matters with uv pip. Pip probably does but I never managed to recreate it. With uv pip order matters albeit with a clear way how.

  • @RanaUniverse
    @RanaUniverse 2 месяца назад

    so is uv is fully same as python pip, i have a problem to manage uv in offline machine pls help me anyone

    • @The_Hynek
      @The_Hynek 2 месяца назад

      If you need concrete help, I recommend dropping by Astral's Discord; people there tend to be very helpful discord.com/invite/c9MhzV8aU5

  • @0xBerto
    @0xBerto 2 месяца назад

    So happy I found this channel (first video) I’d say I’m intermediate level so I definitely want to dig through your videos. Thank you!

    • @The_Hynek
      @The_Hynek 2 месяца назад

      thank you, thank you, thank you! 😊

  • @talideon
    @talideon 2 месяца назад

    The only real issue I've had with uv is that "uv tool"/uvx has a slightly awkward interface compared to pipx. Otherwise, it's been a fantastic improvement over everything that's come before, and I'll be very happy when rye's functionality is fully integrated into it.

    • @The_Hynek
      @The_Hynek 2 месяца назад

      I still occasionally do `uvx run CMD` 😬 Supplanting Rye is a major goal, so only a matter of time.

  • @oasntet
    @oasntet 2 месяца назад

    Boy, I sure hope IndyGreg's github account is never compromised, or he get libxz'd into accepting a PR he shouldn't... I'm amazed you didn't also show the infamous "there are now N+1 standards" XKCD as well. Because, yeah, I've never needed more than pip+virtualenv, sometimes a python manager like tox when needing a lot of python versions. I swear devs don't do an hour of research before diving into solving a problem that's already been solved, repeatedly.

  • @_BonsaiBen
    @_BonsaiBen 2 месяца назад

    Love this content Hynek, funny and informative, and your email newsletter is awesome too :)

  • @MurtagBY
    @MurtagBY 2 месяца назад

    So happy not to use attrs, you can't imagine! Just kidding =) The video has a great pitch, always like the videos despite me not having any idea of how packaging works. I simply use it and it rarely shoots me in the foot. Liked the experience of rye, if uv creates even better tool - I would happily use it in new projects

  • @javierflores09
    @javierflores09 2 месяца назад

    1:54 I gotta say, as a Java developer who only dabbles in python every once in a while, the whole deal with packaging, virtual environments, wheels and so on, has deeply confused me to no end, but after checking out your previous video all the unanswered questions I had in the back of my head have been resolved. Honestly surprised such a well-informed person with entertaining videos like yours has fallen under my radar till now! Instant new sub, hope you keep making videos explaining all these historical aspects about the Python ecosystem in such a concise manner

    • @The_Hynek
      @The_Hynek 2 месяца назад

      I'm very glad to hear it did its purpose! The first video should probably have been two, but I suspect the uv angle lured more people in than if it were just about the packaging part. :)

    • @birdbeakbeardneck3617
      @birdbeakbeardneck3617 2 месяца назад

      name of the vid, i hav exact same need

  • @brenok
    @brenok 2 месяца назад

    Just stumbled over your channel. Keep up the original style. There is charisma. The charisma of a software craftsman that knows his shit and has passion for it. That's the kind of person I love working with. Liked and subscribed :)

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Thank you for finding and appreciating my backcatalog! That video specifically is very dear to my heart. :)

  • @xDarknessCrusherx
    @xDarknessCrusherx 2 месяца назад

    Great video as always! really happy about uv progress recent time, hope we will finally have at least somewhat standard for basic package management needs 😅 Also I really would like to see a video or a blogpost why to write python applications as a packages!

  • @chobblegobbler6671
    @chobblegobbler6671 2 месяца назад

    now remove that old video

  • @bennguyen1313
    @bennguyen1313 2 месяца назад

    So would astral's uv be an alternative to pip... or more like an alternative to nuitka?

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Nuitka is a Python to C++ compiler, that's something different entirely. uv is only about packaging Python code and an alternative to Pip (since last video) and/or PDM/Poetry/Rye (since this video).

  • @MichaelMerickel
    @MichaelMerickel 2 месяца назад

    I love it - keep being awesome Hynek.

    • @The_Hynek
      @The_Hynek 2 месяца назад

      thank you Michael - always great to hear from you! 💜

  • @aspiring_millionaire
    @aspiring_millionaire 2 месяца назад

    Man you have such a good banter, it's fun watching your content and hope to see more of you on here :)

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Thank you! And you and I both hope the same thing ;)

  • @mathiaz943
    @mathiaz943 2 месяца назад

    13:14 have you checked pixi yet?

  • @AbdolaMike
    @AbdolaMike 2 месяца назад

    Love this video i subbed and enjoy your technical videos! i would love a workflow video about how you build an application with UV and how you use UVX with it. Or this could be a blog post whatever you prefer! keep it up!!

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Thank you! 💛 `uv tools` and `uvx` are tools that you don't use with your own project (that would be `uv run`). They are the replacement for `pipx`: so if you have Python tools that you want to use outside of projects, it manages virtualenvs (and Python versions) for you. For example `uvx --from httpie http httpbin.org/json` or `uv tool install --with tox-uv tox` (and then you can run `tox` in your shell whereever you are).

    • @GreatTaiwan
      @GreatTaiwan 2 месяца назад

      @@The_Hynek would love migration video .. i think this fit with most people as a challenging usage while uv init to start a new project is the easiest to do

    • @The_Hynek
      @The_Hynek 2 месяца назад

      The problem with migration videos is "migrate from WHAT?" - one of the problems uv is solving is that currently there's virtually an infinite amount of workflows.

  • @MrAlanCristhian
    @MrAlanCristhian 2 месяца назад

    Hi Hynek, good video. Can you make a detailed video of what it does that env+pip+weel+bash doesn't? Because other than the performance improvement, I don't see any other improvement over the default tools. Even the lacking stuff on uv can be done with what we already have. For example, to install development dependencies you just create a dev_requirement.txt and run pip install -r dev_requirements. What am I missing?

    • @The_Hynek
      @The_Hynek 2 месяца назад

      Until 0.3.0, it was all speed (see my older video - there's a lot more context). Now, most of what uv adds is comfort and misuse safety. As I say in the video: you can give a project to a total newb and they can run `uv run pytest` and uv takes care of EVERYTHING. They can git pull some updates that update dependencies and `uv run` again, and uv will make sure all updates are applied. This eliminates a lot of problems that plagued teams before. Finally, to borrow my own words: the cross platform lock file is the crown jewel of post-0.3.0 uv. It's a HUGE deal if you need to develop across architectures like I do (ARM vs Intel) or across operating systems (macOS vs Linux vs Windows). This works for .txt lock files only when the dependencies are exactly the same, which they often aren't. For this you used to have to use PDM and Poetry that come with their own sets of problems.

    • @MrAlanCristhian
      @MrAlanCristhian 2 месяца назад

      @@The_Hynek thanks!!!

    • @GreatTaiwan
      @GreatTaiwan 2 месяца назад

      @@The_Hynek so does uv run do uv sync first then actually run?

    • @The_Hynek
      @The_Hynek 2 месяца назад

      For all intents and purposes, yes. If you always use `uv run`, any changes to uv.lock (e.g., a git pull) are applied automatically

    • @MrAlanCristhian
      @MrAlanCristhian 2 месяца назад

      ​@@The_Hynek that's nice. I didn't realize that it joins a lot of tools together into a single one, included automatic git pulls and so on. It greatly simplifies the workflow.

  • @marcocaspers3136
    @marcocaspers3136 2 месяца назад

    A binary blob that never breaks? Uhm, yeah that just doesn't exist. Never has, never will.

    • @The_Hynek
      @The_Hynek 2 месяца назад

      We have to see things in relation to the reality that we live in. Yes, there’s the heat end of universe. And yes, Go programs compiled on Jammy don’t work on Focal. But relative to the CURRENT jankiness of existing tools, it‘s IMHO fair to use the mild hyperbole of "never".

  • @hinzster
    @hinzster 2 месяца назад

    uv being written in Rust isn't even a problem (as long as it works). Is nodejs written in javascript? No, it isn't. Bam, it's called precedence.

    • @The_Hynek
      @The_Hynek 2 месяца назад

      There is a bit of history to this angst in the Python community: large parts used to be written in C and we worked for many years to port them to Python, if possible. Making it more approachable and maintainable. That’s how the Mastodon thread starts, in fact. Starting to add Rust is a step back in that sense, but IMO that isn’t really comparable. But it certainly does feel so for some.