Thread
#show-us-what-you-got
    a

    Alex Cano

    2 years ago
    Truly a random question, but I’d like people who know more about asyncio to chime in. I’ve had experience in path building things using it, which is all fine and dandy. I’m curious if there’s any downside to having everything execute within the asyncio event loop, even if you know things are going to be blocking. Like I know you wouldn’t gain any of the advantages of asyncio, but I was just thinking kind of bigger picture. I’m sure there’s some overhead with running code inside an event loop, but I don’t know enough on the topic to know whether it is significant enough to prevent ^.
    Jeremiah

    Jeremiah

    2 years ago
    My $0.02 after working on the Server / Cloud codebase (which is an asyncio application): if you don’t have a way to directly benefit from the concurrency benefits or IO parallelism, I’d stay away. The overhead of debugging code is considerably higher outside a friendly environment like iPython that will let you
    await fn()
    from the repl. On the other hand, if you do have a setup that can benefit from concurrency, even in the last year we’ve seen some huge advances in the async community tooling, lots of credit to Tom Christie for his work on libraries like Starlette and HTTPX
    So I honestly wouldn’t say it’s because of performance in the event loop or not, I’d say purely as a matter of dev experience - if you move a synchronous application into an async framework without any other benefit, you’re going to give up a lot of stuff without proportionate benefit
    a

    Alex Cano

    2 years ago
    Thanks for the input on this! I don’t really have any experience mixing the two, so I wasn’t quite sure where the boundaries would lie. I know there are obvious performance benefits (when the workload allows) for really leaning into the async side of things, and there are code readability and ease-of-use gains when going synchronous. All of this spiraling started when someone asked about an
    AsyncExecutor
    , so I was giving some thought to whether that would be thing I would know how to implement (turns out, it is not!). I wasn’t particularly worried about performance, as ideally most of the flow’s time would be spent doing the actual calculations on the executor instead of running the flow code. I’m still pretty interested in this bridging between the worlds though. Do you know if there’s like a go-to talk or set of blog posts about it? Most of the blog posts I’ve been reading on it are “here is what asyncio is, and here’s how it works if your whole program is async”, which isn’t super helpful for this case.
    Jeremiah

    Jeremiah

    2 years ago
    FWIW, I found this realpython tutorial to be the only thing worth reading on asyncio https://realpython.com/async-io-python/ - sounds like you might be a bit past it though, but it’s my go-to-reference
    Ah the AsyncExecutor… let’s talk when we finally leave 3.5 behind 😉
    a

    Alex Cano

    2 years ago
    Sounds great! Not sure why, but I thought 3.5 support was already dropped! I think I’ll need another cup of coffee! ¯_(ツ)_/¯
    Jeremiah

    Jeremiah

    2 years ago
    Uh you might be right...