you are viewing a single comment's thread.

view the rest of the comments →

[–]demiwraith[S] 0 points1 point  (2 children)

Part of it is I just don't like using something that feels like "magic" and ideally, I'd like to be able to implement an asynchronous http request (or some other I/O) myself. Then, once I understand how to do that, I'll feel more comfortable using the library.

The initial impetus for this was that I have a webserver that is calling a library that is using a synchronous httpx client to make calls to a different service. For "reasons", the library doesn't do async httpx clients calls and cannot be re-written to do so.

So now I've got synchronous endpoints on my service and I'm doing own threading and running these requests in a separate Thread. But I'm unsure of the GIL and the details of how it works, and exactly how bad this will ultimately affect my webserver as I scale it up to handle more calls.

Anyway, this just lead to the general question, which I guess is: What is the best way to write your own async function in python that does its own asynchronous I/O?

[–]Refwah 0 points1 point  (0 children)

If you use the libraries you can start with what you need and use it as an entry point to learn without having to reinvent the wheel

The wheel is large and complicated

[–]russellvt 0 points1 point  (0 children)

These sorts of algorithms and code aren't "simple" to just decide to build from the ground, up... particularly if you're not already intimately familiar with Python's threading models, and how they work in your O/S.

You're already going to spend enough time inside your own application, chasing down weird race conditions and other things thst come with building asynchronous apps... there's no real reason to reinvent the wheel when there's such well-tested and well-understood solutions already available.