Latest / Talk Python To Me / #385: Higher level Python asyncio with AnyIO
Transcript
- 0:00Do you love Python's async and await, but feel that you could use more flexibility or
- 0:04higher order constructs, like running a group of tasks and child tasks as a single operation,
- 0:09or streaming data between tasks, combining tasks with multi-processing or threads,
- 0:15or even async file support? You should check out AnyIO. On this episode, we have Alex Granholm,
- 0:21the creator of AnyIO, here to give us the whole story. This is Talk Python To Me,
- 0:25episode 385, recorded September 29th, 2022.
- 0:29Welcome to Talk Python To Me, a weekly podcast on Python. This is your host, Michael Kennedy.
- 0:47Follow me on Twitter where I'm @mkennedy and keep up with the show and listen to past episodes
- 0:52at talkpython.fm and follow the show on Twitter via at talkpython. We've started streaming most of our
- 0:59episodes live on YouTube. Subscribe to our YouTube channel over at talkpython.fm/youtube to
- 1:04get notified about upcoming shows and be part of that episode. This episode of Talk Python To Me is
- 1:10brought to you by Compiler from Red Hat, an original podcast. Listen to an episode of their show as they
- 1:17demystify the tech industry over at talkpython.fm/compiler. It's also brought to you by us over
- 1:24at Talk Python training where we have over 240 hours of Python courses. Please visit talkpython.fm
- 1:30and click on courses in the nav bar. Transcripts for this and all of our episodes are brought to you by
- 1:36assembly. Do you need a great automatic speech to text API? Get human level accuracy in just a few
- 1:41lines of code. Visit talkpython.fm/assembly AI. Alex, welcome to Talk Python To Me.
- 1:47Thank you.
- 1:48Yeah, it's fantastic to have you here. You have so many cool open source projects out there. We're here to
- 1:53talk about any IO, but actually several of them I've covered on Python bytes on the other podcasts that
- 2:00I run. And we've talked about SQL code gen and typeguard. And I didn't associate that with you
- 2:06specifically and back over to any IO. So yeah, a lot of cool projects you got going on there.
- 2:10Yeah, too many actually. I managed to hand over a couple of them to other people where
- 2:16Seaboard 2 and Sphinx Autodoc type hints, because I'm really the stretched thing at the moment. I barely
- 2:23have time for all of the projects that I'm maintaining.
- 2:26I can imagine. That's, you know, how do you juggle all that? You know, it's, I'm sure you have a full
- 2:32time job and you have all these different projects, right? How do you prioritize?
- 2:35Yes. Yes. Basically, I get the equivalent of a writer's block from time to time. So when that
- 2:41happens, I just either don't try to code up at all, or I just switch to another project.
- 2:47Yeah, true. If you're talking about type hints versus async programming, like if you're stuck on one,
- 2:52you probably are not stuck on the other, right?
- 2:54Yeah.
- 2:54Yeah. Interesting. Well, we're going to have a lot of fun
- 2:56talking about all of them. I doubt there's going to be any writer's block or speaker's block here,
- 3:01podcaster's block. It'll be good. We'll have a good time chatting about it and sharing with everyone.
- 3:05Before we get to that, though, let's hear your story. How'd you get into programming in Python?
- 3:09I got into programming at the age of eight. It was on an MSX compatible machine. I started with BASIC,
- 3:18as so many others did. I did some simple text-based games at first, just playing around. At some point,
- 3:27I got Commodore's Commodore's 128 and I did some simple graphical demos with it. Then I got an Amiga 500.
- 3:38Oh yeah, the Amiga's were cool. They were special.
- 3:41Mm-hmm. Yeah. I dabbled in almost BASIC, then other kinds of tools also. I don't really remember that much of it. Then at some point, I did something with Mac. That is macOS Classic. There was this tool called HyperCard. It's precursor for Flash, basically. So that's something I did some things with. Simple games and whatnot.
- 4:07Yeah. Okay. Skipping forward a bit. I got into PC programming like C++, mostly C. Then I think it was in the latter half of 2005. No, actually it was much earlier in 1999. I started with Perl. Hated it. Then I think the next step was in 2005 when I got to learn PHP. Hated that too.
- 4:34Kept searching.
- 4:35Then finally, finally in 2007, I got to know Python. Then that was Lava's first site, really. At that point, it was, I think, Python 2.5. And of course, I stuck with it.
- 4:49I did some Java professionally for a while, but I never really, really got to love it. It had this corporate industrial feeling to it.
- 4:59Sorry, I'm not dressed up enough to program my Java today. Let me go get my tie. I'll be right back.
- 5:04Yeah. Python was really cool. When I started learning it, my first practical application I made in what, 30 minutes after starting to learn it. It's really staggeringly easy to learn.
- 5:18It is.
- 5:19That's one thing I love about it.
- 5:20It really is. It's one of the few languages you can be really successful with, with a partial understanding of what's going on. Right. You don't even have to know what a class is or what modules are. You can just write a few functions in a file and you're good to go.
- 5:34It's almost like it's English.
- 5:36Yeah. Very cool. Raul out in the audience says, third time's the charm. The third language, you found the one you like there. Excellent. And how about now? What are you doing these days?
- 5:44I've been working for several years on a project, a very complicated project where, okay, this is always a hard part to describe it. It's a sort of working well as application. I'm part of a bigger team. I'm the lead backend developer.
- 6:01It collects IoT data and visualizes it and it provides all sorts of peripheral services to it. This is the first time I really had to spread my wings with databases.
- 6:14Oh yeah. Okay. What technologies are you using there?
- 6:17On the backend, we use TimescaleDB, which is a PostgreSQL extension.
- 6:22Okay.
- 6:23This is for storing that time series data. Then on the backend, we use my framework called Asphalt.
- 6:30I don't know if you've encountered that one. I think it's really cool, but it's not in widespread use. It's not a web framework per se. It's more like a generic framework where you can compose applications from a mix of free-made components and custom-made components.
- 6:48What's it called?
- 6:49Sorry?
- 6:49What was it called?
- 6:50Asphalt.
- 6:50Asphalt. Like the road?
- 6:52Yes.
- 6:52I do not spell it.
- 6:53There we go.
- 6:54Yeah.
- 6:55No. I did a search and I just found a snake and a python snake.
- 6:59Yeah, that's it. That's a good thing.
- 7:01That python snake on some asphalt road. Yeah. You got to be careful here. Okay. Is it a little bit like Flask or what makes it special?
- 7:09Well, Flask is a web framework. This is a generic framework. You can build any kind of applications with it. It doesn't have to be involved with web.
- 7:17I see any network thing, not necessarily HTTP, so it could be UDP or it could be just...
- 7:23It doesn't even have to do any networking at all. You can build command line tools with it. You can just have this mix of components and the YAML configuration to give settings to them all. I think this really would require a whole different session.
- 7:39It does sound like it would be a whole different session, but this is news to me and very interesting.
- 7:44Yeah, I haven't really advertised much. I'm working on version 5 at the moment, which does incorporate any I/O support and it brings the tech up to date with the current standards.
- 7:57Okay. Yeah, this looks very asynchronous based. It's an async I/O based micro framework for network oriented applications, it says.
- 8:05Yeah.
- 8:06And built upon uvloop, which is how all the good Python async things seem to be back these days.
- 8:12Mm-hmm.
- 8:12So it has a lot of sort of modern Python features. It's got async I/O, it's got uvloop, it's got type hints, those sorts of things. When you started in Python in 2007, none of those existed.
- 8:25Yeah.
- 8:26How do you see the recent changes to Python in the last five years or so?
- 8:29I would say that Python has been developing at an incredible speed. I really love it. So many useful stuff coming out with every release.
- 8:36I agree.
- 8:37Yeah, basically from 3.5 to 3.8 or something. There were just so many amazing features that came out then. And now we're seeing these libraries built upon it, right?
- 8:47Right.
- 8:48Right.
- 8:48All right. Well, let's transition over to our main topic that we're going to talk about, which is what I reached out to you for, not realizing the other two interesting projects that I already gave a shout out to are also yours. We'll get to those if we got time.
- 9:01So with Python in 3.4, we had async I/O introduced the actual frameworks that supported that. And then when it really came into its own was Python 3.5 when the async and await keywords were added to the language.
- 9:16Python 3.5. And Python came out of the box with some support for great async programming. But then there are these other libraries that developed on top of that to make certain use cases easier or add new capabilities. And any I/O falls into that realm, right?
- 9:33Yeah. So before we talk about any I/O, we should talk about Trio.
- 9:37Yep.
- 9:38Have you heard about Trio?
- 9:39Yes, I have heard about Trio. I even had Nathaniel on the show, but it's been a little while.
- 9:45That was back in 2018, I talked to Nathaniel. So Nathaniel Smith. So there's probably quite a few changes since then, actually.
- 9:53Yeah, let's talk about Trio.
- 9:54Yeah, actually, the last version of Trio was released just yesterday. The thing about any I/O is that it's an effort to basically bring the Trio features to async I/O land.
- 10:07So Trio is fundamentally incompatible with async I/O. There is a compatibility layer called Trio async I/O,
- 10:15async I/O, but it's far from perfect. So what any I/O does really is allow developers to add these features from Trio to their async I/O applications and libraries, one by one, without making a commitment.
- 10:32For example, at my work, I use any I/O for just a handful of tasks. I think we should talk about the features.
- 10:40Mm-hmm.
- 10:48Async I/O for just a few months, but the other thing about Trio is that they're not going to be able to add them to the same thing.
- 10:56Async I/O does not. So it's kind of a meta-async framework.
- 11:00I see. So it builds on top of these different frameworks, right?
- 11:04Yeah.
- 11:04Yeah. So it builds on top of these frameworks and their underlying primitives.
- 11:08Yeah. So for people who are not familiar, Trio adds things like this concept of grouped tasks.
- 11:16So normally in async I/O, you start one task, you start another. They're kind of unrelated, but
- 11:22even if they're conceptually solving parts of the same problem. And then with Trio, you can do things
- 11:27like create what's called a nursery and then you can have them all run or you could potentially cancel
- 11:32unstarted tasks. And there's other coordination type of operations as well, right? That's the kind of stuff
- 11:39that Trio adds.
- 11:40Yeah. So the point of any I/O is, as I said, to bring these Trio features to async I/O.
- 11:47Right. And because when you do Trio, it's an end-to-end async stack.
- 11:51Yeah. Which means things have to be built for Trio, right? It's like if I have, let's say,
- 11:56HTTPX. I don't know how easy it is to integrate those kinds of things that are expecting an async I/O
- 12:03event loop over into Trio. Well, I already have my own event loop running. It's hard to coordinate the
- 12:09tasks, right?
- 12:10If you're talking about HTTPX, it had a Trio and async I/O backends. Now it defaults to the
- 12:16any I/O backends. So it runs by default on both.
- 12:20Okay.
- 12:20About any I/O features, it provides Trio-like task groups on top of async I/O.
- 12:27Uh-huh.
- 12:27In here, we mentioned that Python 3.11 has its own concept of a task group, but the mechanics
- 12:36are quite a bit different. That requires a bit of explaining.
- 12:40Yeah. How does it work here?
- 12:41The thing is that async I/O task group, so not this one, but the standard library task groups,
- 12:49which are in Python 3.11, they basically just start normal async I/O tasks and you can cancel
- 12:57use the task objects with using the task objects that come out of the create task method.
- 13:03So what sets any I/O task groups apart from async I/O task groups is the way cancellation is done.
- 13:10And since any I/O was designed based on Trio, when you do start soon, it doesn't return any task
- 13:20objects that you can cancel. Instead, cancellation is done via so-called cancel scopes. So each task group
- 13:26has its own cancel scope. If you cancel that, you basically cancel all the underlying tasks, but it goes even deeper.
- 13:36Because this is a bit complicated, so bear with me. Cancellation is not done on a per-task basis,
- 13:43but on a per-cancel scope basis. You can have cancel scopes nested so that if you start a task and it starts
- 13:51a cancel scope, you can just cancel that scope and it cancels everything up to that point.
- 13:57Okay. So like if I call a task, if I create a task and then somewhere inside for it to do its job,
- 14:04it also creates a task. Those can be grouped into the same basic scope, right? So there's not these
- 14:10like children tasks running around. Yeah. You don't even have to start another task. If you cancel a
- 14:16cancel scope, then anything you basically wait on gets automatically canceled. Bam. This is called
- 14:23level cancellation in contrast to the edge cancellation mechanism employed by any SEKIO.
- 14:30In edge cancellation, you just cancel the task once and it gets canceled error raised in the task. So you can
- 14:42ignore it, which is by the way, bad thing to do, but then the task won't be canceled again. Usually there
- 14:48are exceptions to this, which are a topic of debate in the community, but the cancel scope basically,
- 14:56they define boundaries for cancellation. So if you say you cancel a task group's canceled scope, only the tasks
- 15:04started from that task group are canceled. So when those tasks return back, so all the tasks are done,
- 15:11then the code just goes forward from this async context manager. Basically when all the tasks are done,
- 15:18then however they end, unless some raised exceptions, that's a different situation. If they were either
- 15:26canceled or successful, then the code just goes forward to the all tasks finished part.
- 15:32This is really neat. The other thing that's standing out here as I think about these task groups. So for
- 15:38those of you listening, you can just create an async with block to create the task group. And then
- 15:42in there you can just say task group dot start soon and give it a bunch of async methods to start
- 15:47running. One of the things that's cool about this is it automatically waits for them all to be finished
- 15:52at the end of that context manager, the with block, right?
- 15:55The standard library task groups work the same way actually.
- 15:58Okay. And those are in 3.11?
- 15:593.11? Yes. Yep. We'll see how the mechanism will work. There's a new mechanism for cancellation
- 16:06on cancellation of tasks. It's not really battle tested. It's something that was added fairly late
- 16:14in the game to 3.11. So it's not yet clear if there are edge cases where it fails totally. This is also
- 16:23a debated topic in the community. Sure. The other thing here that I wanted to ask you about is you don't
- 16:28say like create task and you don't say start, you say start soon. Why do you say what's this like
- 16:35uncertainty about? Tell us about that. Okay. So start soon. It's actually does the same thing as create
- 16:42the task because creating task doesn't start running it right away. It starts only running it on the
- 16:48perhaps over the next iteration of the event. Right. Or maybe not. Maybe the event loops all backed up.
- 16:53Maybe it's the, you know, it takes a while, right? Yeah. So it's basically the same as a loop that
- 16:59calls soon. So you schedule a callback. That's all that tasks are. They are callbacks with bells and
- 17:05whistles. Start soon is modeled based on trial, but it's, I should mention that there's also a method called
- 17:12start, which works a bit differently. This showcase is the start method. So this is very, very useful.
- 17:20This feature is not present in the standard library task groups. So basically it's very useful starting
- 17:27a background service that you need to know that the task has actually started before you move on.
- 17:33So in the example that you have on the docs here is you create a task group. And the first thing is to
- 17:37start a service that's listening on a port. The next thing is to talk to that service on the port.
- 17:42Right. And if you just say, kick them both off, who knows if that thing is actually
- 17:46going to be ready by the time you try to talk to it. Exactly. This is something I use in practice all
- 17:51the time. And this is different than what you would get just with the asyncio create task or whatever, right?
- 17:56Yeah. And even the new task group feature doesn't have this.
- 18:02This portion of talk Python is sponsored by the compiler podcast from Red Hat. Just like you,
- 18:08I'm a big fan of podcasts, and I'm happy to share a new one from a highly respected open source company,
- 18:13compiler and original podcast from Red Hat. Do you want to stay on top of tech without dedicating tons
- 18:19of time to it? Compiler presents perspectives, topics and insights from the tech industry,
- 18:24free from jargon and judgment. They want to discover where technology is headed beyond the headlines and
- 18:28create a place for new IT professionals to learn, grow and thrive. Compiler helps people break through
- 18:34the barriers and challenges turning code into community at all levels of the enterprise.
- 18:38One recent and interesting episode is there, the great stack debate. I love, love, love talking to
- 18:44people about how they architect their code, the tradeoffs and conventions they chose, and the costs,
- 18:49challenges and smiles that result. This great stack debate episode is like that. Check it out and see if
- 18:55software is more like an onion or more like lasagna or maybe even more complicated than that. It's the first episode
- 19:02in compiler series on software stacks. Learn more about compiler at talkpython.fm/compiler. The link is in your
- 19:09podcast player show notes. And yes, you could just go search for compiler and subscribe to it, but follow that link and
- 19:16click on your players icon to add it. That way they know you came from us. Our thanks to the compiler podcast for keeping
- 19:23this podcast going strong.
- 19:27So I guess you could in the standard library, you could start it and then you would have to just
- 19:32wait for it to finish and then you would carry on. But it's like two steps, right?
- 19:37The workaround would be to create a future, then pass that to the task and then wait on that future. So it's a
- 19:45bit cumbersome. And then you have to remember to use a try, accept in case that that task happens to fail. Otherwise, you end up waiting on the future forever.
- 19:55Mm hmm. Another, I really like this idea. Now, the other thing that I don't see in your examples here,
- 20:02where I'm creating a task group and starting these tasks and waiting for them to finish is
- 20:06management of the event loop. If I was doing that with my code, I'd probably have to create a group
- 20:12or a loop and then like, you know, call some functions on it. And, and here you just use any IO. What, where's the event loop being managed?
- 20:20I'm not sure. What do you mean? Well, like a lot of times when you're doing async stuff,
- 20:26you have to go and actually create an async event loop and then use the loop directly.
- 20:31And, you know, you're working with a loop for various things.
- 20:34And well, there is that a run command at the bottom. Yeah. Yeah. Okay. So basically the,
- 20:40you just say any IO dot run or asyncio dot run. Okay. And I can, if, even though I'm using the
- 20:45any IO task groups, I can still just, I can mix and match this with like more standard asyncio event
- 20:52loops. That's the premise. So you can just, like, ease into it. Nice.
- 20:57So for example, if I have a FastAPI web app and you know, FastAPI is in charge of manning the event,
- 21:05managing the event loop. And if I've got like an async API endpoint, I could still go and use an
- 21:10any IO task group and get all the benefits in there. Yep. Okay. That's beautiful.
- 21:15I should mention that FastAPI also depends on any IO. Oh really? Okay. Yes.
- 21:19How interesting. Yeah. I've seen Sebastian Ramirez talking about some, some little functions that he
- 21:24wrote and he's like, I would love to see these just get back into any IO. I didn't realize that
- 21:28FastAPI itself was using them. Yeah. Okay. So very useful. We've got these task groups. We've got the
- 21:36concept of cancellation. Another one that's not exactly cancellation, but as, as sort of cancellation is
- 21:43timeouts. Do you want to talk about how you do timeouts? Yeah. I meant to talk about that. As I recall,
- 21:50in Python 3.11, there is a, it's a similar construct. I think it was a with timeout or some asyncio.timeout or
- 21:57something similar. I don't remember really, but what this move on after does is it creates a cancel scope
- 22:05with a timeout. Basically, this is a very, very practical use of cancel scopes. What it does is it
- 22:12start a timer and after one second, it cancels this scope. So anything under that gets canceled.
- 22:20So in this case, just at the sleep command gets canceled and then the task just keeps going.
- 22:27So the way you described it before, it sounds like if there was a bunch of tasks running,
- 22:30if any of them try to await something, they're also going to get canceled. Is that right?
- 22:35In this case, you mean? Yeah. No, only the part that is within the with block.
- 22:40Right. Well, that's what I mean. But if you had done multiple tasks within like the move on after,
- 22:44right? Like I say, I try to talk to the database to insert a record and I try to call an API and
- 22:49the database times out. Within a single move on after block, you can only have one thing going on,
- 22:55which is the await here. So even if you start multiple tasks from that task group, they are not
- 23:01enclosed within that cancel scope. I realized that castle scopes are complex and difficult concept.
- 23:07And I don't think I can adequately explain them, but I hope that this will at least
- 23:13give some shit some light into that. Yeah. It's a really cool idea because your code could,
- 23:20it's async. So it's not as bad as if you were to like lock up waiting for an API call or something
- 23:27that's going to time out on the network eventually after a really long time. But it's still a
- 23:32cancellation. Still, you don't want it to clog up your code, right? You want to just say,
- 23:35sorry, this isn't working. Yeah. One place where I often use a construct like this is finalization.
- 23:42So when you are closing up things, then you can use this, this move on after to the timeout for closing
- 23:49resources. Yeah, that makes sense. Because you want to be a good citizen and in terms of your app and
- 23:54release the resources as soon as possible, like a database connection or a file handle. But if it's,
- 23:59if it's not working, you know, like, oh, I made it. I made a try at it after a second. We're done.
- 24:04Exactly. And also, I should mention that this is where any of your biggest caveat lies. It is in
- 24:11in finalization. I often run into problems with the cancel scopes because the thing with cancel scopes is that
- 24:20that when you run code within a cancel scope and that scope gets canceled, then anything awaiting on
- 24:28anything within that cancel scope is always canceled time after time. So you cannot wait on anything as
- 24:35long as you are within the cancel scope. And asyncIO code is not expecting that. So it might have a final
- 24:43clause where it does await, say, connection.close. But that also gets canceled if you are within an
- 24:49NEIO cancel scope. And it's one of the biggest practical issues with NEIO right now. And we are
- 24:56trying to figure out the solution for that. Just something to keep in mind when you are writing
- 25:03NEIO stuff. Yeah, that is tricky, right? But help us on the way.
- 25:06You say, well, I'm going to try to call this web service and I'm going to wait it. And if it fails,
- 25:11you know, probably internally, what you want to do is close the network connection as well.
- 25:15Right. But if you try to wait closing the network connection. Yeah. So what happens there? Does it
- 25:21eventually just get cleaned up by the garbage collector or dereferenced?
- 25:25Well, garbage collector doesn't work that well with async stuff because the destructors could be called
- 25:31in any thread. So you can't rely on that. You can't do any async callbacks in the destructor. So it's a
- 25:39better, it's a good idea not to try any of that and instead just raise a resource warning. If you're
- 25:45you're writing any I/O where code, you would have either this shielded cancel scope or better yet,
- 25:52a move on after which shield true. What does that do? At least temporarily protects the
- 25:57the kind of test from cancellation. So let's say you have move on after say five and with shield true.
- 26:06It means that even if the outer cancel scope is canceled, your actual task will start running until
- 26:12it exists as cancel scope or if the timeout expires. So you have a five second window to close any
- 26:19resources that need closing. Got it. And so you just create a, you could do that say within your exception
- 26:24handler or something, right? Yeah. Okay. Or actually, I think finally,
- 26:29a finally block might be the best place to do that. Sure.
- 26:32But depending on the audio use case, of course. Yeah, of course. Okay. Very interesting. So all
- 26:37this stuff about task groups and scheduling tasks and canceling them, that's very trio-esque, but it's
- 26:43also just a small part of any I/O. There's a bunch of other features and capabilities here that are
- 26:51probably worth going into. Some cool stuff about taking async I/O code and converting it to threads or
- 26:57converting threads to async I/O and similarly for sub processes. But let's maybe just
- 27:02talk real quick about the synchronization primitives. These are things like events, semaphores. Maybe
- 27:08not everyone knows what events and semaphores are in this context. Give us a quick rundown of that.
- 27:13Yeah. Well, these are pretty much the same as they are on async I/O. Many of them use just the async I/O
- 27:19counterfeits straight up. So events are a mechanism for telling another task that something happened,
- 27:28something significant, a significant happened, and they need to react to it. It's often used to
- 27:32coordinate the tasks. So one thing doesn't happen before something else has happened in another task.
- 27:38Yeah, there might be two tasks running and one says, I'm going to wait until this file appears.
- 27:43And the other one's going to eventually create the file, right? But you don't know the order.
- 27:47Yeah. So one option is to just do polling. Like, well, I'm going to async I/O.sleep for
- 27:52a little while and then see if the file's there. Try to access it, you know, and do that over and over. A much more
- 27:58responsive way and deterministic way would be to say, I'm going to wait on an event to be set. And the thing
- 28:06that creates the file will create the file and then set the event, which will kind of release that other task to carry on. Right?
- 28:11Right. Moving on, semaphores are a mechanism for saying that you have this limited, you have a number of limit,
- 28:21let's say a connection pool or something. And you want to specify that whenever some part of the code needs
- 28:28to access to this resource, it needs to acquire the semaphore. So you set a limit, and then each time
- 28:36a task enter, that's a semaphore, that decrements the counter. And when you hit the limit, then it
- 28:43starts blocking until something else releases it. Right. So people might be familiar with thread locks
- 28:49or async I/O's equivalent, where you say only one thing can access this at a time. So you don't end up
- 28:55with deadlocks or race conditions and so on. But semaphores are kind of like that, but they allow
- 29:01multiple things to happen. Say maybe your database only allows 10 connections, or you don't want to have
- 29:06more than 10 connections. So you could have a semaphore that says it has a limit of 10 and you have to
- 29:12acquire it to talk to the database. That doesn't mean it stops multiple things from happening at once. It
- 29:17just doesn't let it become a thousand at once. Right? Exactly. I really like this idea. And I was
- 29:22showing some people some web scraping work with async I/O where it's like, oh, let's go create a whole bunch of
- 29:29ACPX requests or whatever type of requests, you know, something asynchronous talking to some
- 29:36servers to download some code. And if it's a limited set, you know, no big deal. But if you have
- 29:41thousands of URLs to go hit, well, then how do you manage not killing your network or overloading that?
- 29:47And the semaphore actually would be perfect. So for people listening, the way that you do it is you
- 29:52create a task group and then just you pass the semaphore to start soon. That's really clean. And then
- 29:57any I/O takes care of just making sure it gets access and then runs and then gives it back. How's that work?
- 30:02I'm not sure what sort of answer you are expecting, but as I recall, this current implementation is
- 30:09actually using the underlying async libraries events. Okay. So there are actually methods to
- 30:16acquire and release the semaphores. It just implements an async context manager that acquires it at the
- 30:23beginning and releases it at the end. There's an event involved for notifying the any awaiting task that
- 30:31it has a semaphore slot available. It's super clean. And the fact that you don't have to write that code,
- 30:37you just say the semaphore is associated with this task through your task group. I really like it.
- 30:42Actually, semaphores are not associated with a particular task. That's what capacity limiters are for.
- 30:47Okay. So you can release a setup from another task while capacity limiters are bound to the specific
- 30:55task that you acquired them in. Okay. Yeah. And the semaphore example, was it being passed? Oh, yeah.
- 31:00It's just being passed as an argument, isn't it, to the task. And it's up to the task to use it. I see. Okay.
- 31:06So this other concept, the capacity limiter. Yeah. It sort of does that. Yeah. So this is from Trio. It's very similar to the semaphore. So you can set, you can actually set the borrower. But in most circumstances, you want the current task to be the borrower. And limiters are actually used in other parts of any IO as they are in Trio. For example, to limit the number of threads that you allocate,
- 31:34or limit the number of sub processes that you spawn. Sure. You don't have too many sub processes, right? You've got a thousand jobs and you just for each thing a job, start it in a sub process. You're going to have a bad time. Right. So as documentation says, they are quite like semaphores, but they have additional safeguards. Such as? Well, they check that the borrower is the same. Okay. Yeah, that makes sense. So by default, they check that the task they are used for both acquiring or releasing on the
- 32:04Yeah, nice. Okay. Well, this I didn't know about capacitor, capacity limiters. That's fantastic. I love the idea. Okay. Let's jump over to you talked about the threads, and the sub processes. Let's talk about this thread capability that you have here. This is very nice. Any IO dot two thread. What is this?
- 32:23Yeah, so this is also modeled based on trio. It's basically any IO's way of doing worker threads. So in asyncio, you have these thread pool executors that do the same as run sync. Async IO's API is somewhat problematic because you have basically two methods.
- 32:45So you have, I forget the older one, the newer one is called two thread. The first one was what it run in executor, whatever, whatever it was. They both have their own issues. Two thread doesn't allow you to specify any thread pool. So it always uses the default thread pool. And there is no way to add that to the API because it was done in such a manner.
- 33:09Then the older function does have this parameter at the front. But the problem is that it doesn't propagate context variables, unlike the newer two thread function. So context variables, if you don't know about them, they are a fairly recent addition to Python.
- 33:26Yeah, what are those?
- 33:27They are basically thread locals. Are you familiar with thread locals?
- 33:31Make a comment for people who don't know, like thread local variables, which also exist in Python, allow you to say, I'm going to have a...
- 33:39variable, maybe it's even a global variable, and it's thread local, which means every thread that sees it gets its own copy of the variable and where it points to and what value it is.
- 33:51And so that way you can initialize something at the start of a thread. If you have multiple threads, they can all kind of have their own copy so they don't have to share it.
- 33:59But that falls down because asyncio event loops, when you await those, all that stuff is running on one thread, just the one that's running the loop. That's what you're talking about is that equivalent, but for asyncio, right?
- 34:12Yeah, so context variables are much more advanced concept. They basically, yeah, as you said, thread locals for async tasks.
- 34:21That sounds very tricky. I've thought about that. I have no idea how to implement that. So that's pretty cool. I guess Python would know.
- 34:26Yeah, the thing is, when it starts running a task, when it switches between tasks, it runs that callback within that context that the task is tied to.
- 34:39Right. So this has been somewhat of a problem because that older method in asyncio for running worker threads, it doesn't propagate these variables, but the newer function to thread does.
- 35:02But then you can specify which thread pool you want to use.
- 35:07Right. Okay, so it's similar to the built-in one, but it gives you more capability to determine where you might run it.
- 35:13Yeah. When you call run sync, it allows you to specify a limiter, and it uses the default limiter, which has a capacity of 40 threads.
- 35:2340? That seems like a pretty good default. Much more than that, and you end up with memory and context switching issues.
- 35:30Yeah. It was arbitrarily set to 40, but then Nathaniel and Trio, so I just followed suit.
- 35:37Sure. Yeah, so basically, if you've got some function that is not async, but you want to be able to await it so that basically run it on a background thread, here you just say any IO dot to thread, and then dot run sync, and you give it the function to call.
- 35:54And now you can await it, and it runs on a background thread in this thread pool, which is really nice.
- 35:59Yeah, that's how it works.
- 36:00So one thing that I'm noticing a lot in the API here for any IO is often, now for the synchronous functions, it's completely obvious why you wouldn't do it, but even in the sort of creating tasks ones, what I'm noticing is that even the async functions, you pass the function name and then the arguments to like start soon, as opposed to saying, call the function, passing the arguments, and getting a coroutine back.
- 36:29Why does it work that way?
- 36:30It seems like it would make it a little less easy to use, like, say, type hands and autocomplete and various niceties of calling functions and editors.
- 36:38Yeah, there was a good reason for that.
- 36:40I can't remember that offhand, but at the very least, it's consistent with the synchronous counterforce, like run sync.
- 36:48Yeah, cool.
- 36:49All right, so we have this stuff about threads, and you have the to thread, also from thread, which is nice.
- 36:55What's from thread to?
- 36:56Yeah, so when you are in a worker thread, and you occasionally need to call something in the event loop thread, then you need to use this from thread to run stuff on event loop thread.
- 37:08Right, because the worker method is not async.
- 37:12Otherwise, you would just await it, right?
- 37:13It's a regular function.
- 37:15But if in that regular function, you want to be able to await a thing, you can kind of reverse back.
- 37:20I see.
- 37:20That's an interesting bi-directional aspect.
- 37:22All right, subprocesses.
- 37:24We all know about the GIL, how Python doesn't necessarily love doing computational work across processes.
- 37:31Tell us about the subprocess equivalent.
- 37:34This is a relatively easy way to both run tasks in a subprocess and then opening arbitrary executables for running asynchronously.
- 37:46AsyncIO has similar facilities for running async processes, but these async subprocess facilities are not really up to par with, say, multiprocessing, which has some additional nice things like async shared queues and other synchronization primitives.
- 38:05But they are still pretty useful as they are.
- 38:09Yeah.
- 38:09So basically, you can just say anyIO.toProcess run sync and you give it a function and now you can await that subprocess multiprocessing.
- 38:20Yeah.
- 38:20There are the usual caveats like because they don't share memory, then you have to serialize the arguments and that could be a problem in some cases.
- 38:30Sure.
- 38:30So basically, it pickles the arguments and the return values.
- 38:35It sends them over.
- 38:35Yeah.
- 38:36It could be even so that the arguments are pickable, but the return value is not, which obviously causes some confusion.
- 38:44Yeah.
- 38:44Yeah.
- 38:44Absolutely.
- 38:45People maybe hear that pickling is bad and you can have all sorts of challenges like code injection and whatnot from pickling through security.
- 38:54So this, I would think, is not really subject to that because it's you calling the function directly.
- 39:00Right.
- 39:01It's like completely just inside.
- 39:03There's no way to inject anything bad.
- 39:05Yeah, exactly.
- 39:06It's all the multiprocessing that's handling it anyway.
- 39:09So it should be okay.
- 39:09Yeah.
- 39:10Yeah.
- 39:10Cool.
- 39:10Another one that is pretty exciting has to do with file support.
- 39:15So we have open in Python.
- 39:18And you would say with open something as F, right?
- 39:23But that's, there's no async equivalent, right?
- 39:25Yeah.
- 39:25These file facilities are really just a convenience that wraps pictures around these file objects.
- 39:33Yeah.
- 39:33So if somebody wants to know, there is no actual async file IO happening because that's not really a thing on Linux.
- 39:40And even on Windows, it has terrible problems.
- 39:44Okay.
- 39:44So what's happening with this any IO dot open file?
- 39:47It opens a file in a thread and then this opens, it starts an async context manager that on exit closes the file.
- 39:55And it also closes the thread, I guess, right?
- 39:57Well, it uses throwaway threads.
- 39:59Okay.
- 39:59Basically from the thread pool.
- 40:01All right.
- 40:01I see.
- 40:01So it'll use a thread to open the file and get the file handle and then throw away the thread.
- 40:07And then does it do something similar?
- 40:09Well, return the thread to the pool.
- 40:10Yeah.
- 40:10Yeah.
- 40:11Return to the pool, which is much better than creating it and throwing it away completely.
- 40:17Also that read call is done in the shed.
- 40:19Okay.
- 40:20So it just is sort of a fancy layer over top of thread pool.
- 40:23But it's really, really nice.
- 40:25You write basically exactly the same code that you would write with regular open and a context manager, but the async version.
- 40:33Although I got to say that the opening part of creating a context manager here, you say async with, which people are probably used to.
- 40:40And then async with await open file, which is, it's a bit of a mouthful.
- 40:45The reason for that is because you can just do await open file and then go about your business and then manually close the file.
- 40:53Got it.
- 40:53I'm not sure if there's a more convenient way to do this.
- 40:57I might be open to adding that to any IO, but for the moment, this is how you do it.
- 41:01Yeah, you could probably wrap it in some kind of class or something that's synchronous, but then has an A enter.
- 41:06But yeah, I'm not sure if it's totally worth it.
- 41:09But yeah, that's quite the statement there.
- 41:11And the other area that's interesting about this is if you want to loop over it line for line, instead of doing a regular for loop, you can do an async for line in file and then read it asynchronously line by line, right?
- 41:25Yeah.
- 41:25So the A next method just gets the next line in the worker side.
- 41:30Yeah, this is fantastic.
- 41:31So people are working with files.
- 41:33They definitely can check this out.
- 41:34And also related to that is you have an asynchronous pathlib path.
- 41:40Yeah, that's a fairly recent addition.
- 41:42Yeah, it looks great.
- 41:43So you have like an async iterator.
- 41:46You have an async, is it a file, async read text, all built into the path, which, you know, is like what's built into a regular path, but not asynchronous.
- 41:53Yeah, quite nice.
- 41:55We're getting kind of short on time here.
- 41:57What else would you like to highlight here?
- 41:58That's really important.
- 41:59I would like to highlight the streaming framework here because it's one of the unique things in any IO.
- 42:05Okay.
- 42:05Yeah, let's talk about it.
- 42:06Trio has its channels and then it has Socas and whatnot.
- 42:11But any IO has something that Trio doesn't have.
- 42:14And really, asyncio has some kind of streaming abstraction, but not quite on this level.
- 42:21In any IO, we have a streaming abstract base class hierarchy.
- 42:25We have object streams and byte streams.
- 42:29The difference between these are that object streams can have anything like the integers, strings, any arbitrary objects.
- 42:39And byte streams have only bytes and they are modeled according to TCP.
- 42:44With byte streams, you can send a number of bytes or receive bytes, but they might be chugged differently.
- 42:51These are abstract streams.
- 42:53So you can, say, build a library that wraps another stream.
- 42:57Say you build an SSH client that creates a tunnel and it exposes that as a stream.
- 43:04So long as you are able to consume a stream, you don't have to care how the stream works internally or what other streams it wraps.
- 43:14A good example of a stream wrapper is the TLS support.
- 43:19That's right there.
- 43:20So TLS support in any IO can wrap any existing stream that gives you bytes, even if it's an object, whether it's an object on or byte stream.
- 43:32So it does the handshake using the standard library.
- 43:35Actually, standard library contains this sense IO protocol for TLS.
- 43:40Okay.
- 43:41Sense IO protocol, if you are not aware of it, it's basically a state machine without any actual IO calls.
- 43:48It's a very neat protocol implementation that lets you add whatever kind of IO layer you want on top of that.
- 43:54So this is what any IO uses to implement TLS.
- 43:57So you have both a listener and a connect and a TLS wrapper.
- 44:02So any kind of TLS, you can even do TLS on top of TLS if you like.
- 44:07I'm not sure that's useful, but you can do it.
- 44:10It's super encrypted.
- 44:12Yeah, this is very flexible.
- 44:14We have all sorts of streams that even these unreliable streams, which are modeled based on UDP.
- 44:21Oh, really?
- 44:22Okay.
- 44:22So UDP is implemented by using these unreliable streams.
- 44:28I don't think there are any more unreliable streams implementations than UDP.
- 44:32But yeah, I'm really part of this streaming class hierarchy.
- 44:37And it's too bad that there are no cool projects to show off this system.
- 44:42But maybe in the future we will have.
- 44:44Another thing that I would like to highlight is a system of type attributes.
- 44:50That has been really useful in practice.
- 44:52Yeah, before we move on to the type attributes, let me just ask you real quickly.
- 44:55Can I use these streams and these bidirectional streams where you create like a send stream and receive stream?
- 45:02Can we use those across like multiprocessing or to coordinate threads?
- 45:08I'm sure we could use it for threads, right?
- 45:09Sadly, no.
- 45:11Sadly, no.
- 45:12This memory object stream is, as they call it in TRIO channel.
- 45:16This is one of the most useful pieces of NEI, really.
- 45:20I use this every day at work.
- 45:22So these are basically like cues on steroids.
- 45:25Yeah, exactly.
- 45:26That's what I was thinking.
- 45:27Unlike ASYNCIO cues, you can actually close these.
- 45:30You can clone them.
- 45:32So you can have multiple tasks waiting to receive something like workers.
- 45:36And we have multiple senders.
- 45:39I see.
- 45:39Like a producer consumer where some things are put in, but there's like five workers who might grab a job and work on it.
- 45:45You can have five consumers and five producers all talking to each other.
- 45:48Yeah.
- 45:49And then you can just iterate over them.
- 45:51Also not possible with cues.
- 45:53You can close the cues, sorry, streams, so that when you iterate on them, if all the other other ints are closed, then the iterator adjusts the ints.
- 46:03Oh, wow.
- 46:03Okay.
- 46:04So if the send stream goes away, then the receive stream is done.
- 46:08It's at the end.
- 46:09Yeah.
- 46:09That's fantastic, actually.
- 46:11I really like that.
- 46:12Yeah.
- 46:12I think this is also coming to...
- 46:14Go ahead.
- 46:14Sorry.
- 46:14...asyncIO.
- 46:15Okay.
- 46:15I think this is also coming to the standard library.
- 46:18Nice.
- 46:19All right.
- 46:19At some point.
- 46:20Last thing we probably have time for here that you wanted to highlight is typed attributes.
- 46:25What's the story of typed attributes?
- 46:26If you knew about the asyncIO extras in...
- 46:30I think they have both in protocols and streams.
- 46:33For example, with TLS, you want to get the certificate from the stream.
- 46:39Like if you have negotiated a TLS stream, you want to get the client certificate, right?
- 46:44So this is a type of way to do it.
- 46:47You can add any arbitrary extra attributes to a stream.
- 46:50Just declare it in the extra attributes method.
- 46:54But the niftiest part here is that it can work across wrapped streams.
- 46:58A very good example is that say you have a stream that is based on HTTP.
- 47:03You have an HTTP server and you have access to a stream, let's say, WebSockets.
- 47:08Then you want to get the client IP address.
- 47:12Well, usually you may have a front-end web server like Nginx at the front.
- 47:18Normally, what you would get when you ask for an IP address, you actually get the IP address of the server.
- 47:24What you need to do is look at the headers.
- 47:27This is something you can do transparently with these type attributes.
- 47:30So basically, wrap a stream that understands HTTP, you can have that handle the request for the IP address, the remote IP address,
- 47:40and have it look at the headers and look for a forwarded header and return that instead.
- 47:45Nice.
- 47:45Let me see if I got this right here.
- 47:47So people are probably familiar with Pydantic.
- 47:49And Pydantic allows you to create a class and it says what types are in the class and the names and so on.
- 47:56And those serialize out a JSON message.
- 48:00It sounds to me like what this is built for is when I'm talking binary messages over a stream like a TCP stream, I can create a similar class that says, well, I expect a message that is a string and then a float.
- 48:14Read that out of the stream.
- 48:16Is that right?
- 48:17Yeah.
- 48:17A good example here is if you go back to the streams part.
- 48:21Text streams.
- 48:22Okay.
- 48:23So this is something that translates between bytes and streams on the fly.
- 48:28So this is a perfect trivial example of a stream prepper.
- 48:32Okay.
- 48:33Yeah.
- 48:33So you have a text received stream that will do the byte decoding.
- 48:37Yeah.
- 48:37Yeah.
- 48:37Very nice.
- 48:38And you don't have to care like what's downstream of that.
- 48:41And even if you have three layers on top, you can just still ask for, say, client remote IP address.
- 48:49If there's a network stream somewhere downstream, that's the stream that will give you your answer.
- 48:55Cool.
- 48:55Yeah.
- 48:55The stream work here is really nice.
- 48:58There's a lot of things that are nice.
- 48:59The coordinating, the task groups, the coordinating limitations, like with a limiter, capacity limiter.
- 49:08A lot of cool building blocks on top of it.
- 49:11And also the fact that this runs against or integrates with regular asyncio means you don't have to completely change your whole system in order to use it.
- 49:20Right?
- 49:21Yeah.
- 49:21Very cool.
- 49:21All right.
- 49:22Well, I think we're about out of time to talk about any IO.
- 49:24Do you want to take 30 seconds and just give the elevator pitch for SQL A code gen?
- 49:31This is a really exciting project that you created here.
- 49:34Yeah.
- 49:34This is one of those side projects that are on the verge of a major release.
- 49:38So what this does is it takes an existing database.
- 49:44It connects to an existing database, reflects the schema from that, and then writes modal code for you.
- 49:51The next major version even supports data classes and other kinds of formats.
- 49:57The SQL model one is the one that's most exciting for me because that'll give you Pydantic models that use a SQL model, which is very exciting.
- 50:05Yeah.
- 50:06So nice.
- 50:06What else?
- 50:07Think if you're a consultant or you talked about Java earlier, right?
- 50:12Imagine you've got like a Java code base and you want to do a proof of concept in Python and SQL model or SQLAlchemy.
- 50:18And somebody says, well, why don't you try building a simple version that talks to our database?
- 50:24And if that thing has like a hundred tables and complicated relationships, it's no fun to sit down.
- 50:31Like a big portion of that project might be just modeling the database.
- 50:34And here I can just say SQL A code gen, connect to Postgres.
- 50:38Boom.
- 50:39Out comes SQLAlchemy classes.
- 50:40That's a huge jumpstart for getting started.
- 50:43Or if you're a consultant jumping into a new project.
- 50:45Yeah, exactly.
- 50:46If you have a really large database in this, we will save little hours, you'll feel time.
- 50:51At least hours, yes.
- 50:53And a lot of frustration, right?
- 50:56Because with like SQLAlchemy, you've got to have the model match the database just right.
- 51:01And this will do that for you.
- 51:03Yeah.
- 51:03Okay.
- 51:04Super cool project.
- 51:05Typeguard is another one you have.
- 51:06Not super complicated, but an interesting capability to grab on.
- 51:10Yeah.
- 51:11Also one of those that are on major of a version of a major release.
- 51:16I sadly have not had enough time to finish the next major version.
- 51:21And then there's of course, Python 3.11, which brings a whole bunch of new features that I have not been able to yet incorporate into Typeguard.
- 51:31And sadly, I also have not started using it myself.
- 51:37It's a sad story really.
- 51:40Yeah.
- 51:40Okay.
- 51:41But the premise is that you have this pytest plugin.
- 51:45You activate it during the test run.
- 51:47And then in addition to static type checking your application, which you usually do with mypy, Pyright or what have you.
- 51:57You can also do a runtime type checking because the static tools don't always see the correct types.
- 52:05You might not be in control of that, right?
- 52:06You might write a library.
- 52:08Your library might have types declared on what it's supposed to take.
- 52:11The person consuming your library has no requirement to run mypy.
- 52:16And they have no requirement to make sure what they typed matches what you said you expect.
- 52:21And because they're hints, they're not compiled options in Python.
- 52:25It might at runtime, you might get something you don't expect, even though you put a type there.
- 52:30Yeah, exactly.
- 52:31So this is how you get the runtime assurance that you have the right type there.
- 52:37Nice.
- 52:37So all you do with this type guard library is you put an at type checked decorator on a function?
- 52:42The best way would be to use the import hook.
- 52:46Okay.
- 52:46So there's an import hook that will automatically add these decorators while doing the import.
- 52:52So you don't have to alter your code at all.
- 52:55There are some open issues with that import hook.
- 52:58Like somebody reported that this import hook is installed too late.
- 53:02The modules in question were already imported.
- 53:06So that's something I have yet to fix or find a workaround for.
- 53:10Sure.
- 53:10That's the idea.
- 53:11Right.
- 53:12So you can either use the decorator and be somewhat guarded about how you're doing it and only apply
- 53:18to certain parts, like say your public API.
- 53:20Or you could just say install import hook and then everything that gets imported gets wrapped
- 53:25in the type checked decorator.
- 53:26And what that does is it looks at the type hints and the declared return value and will raise
- 53:32an exception if say you say that your function takes an integer and it's passed a string.
- 53:36That becomes a runtime error.
- 53:38Right.
- 53:38Or you can just issue a warning.
- 53:41Sure.
- 53:41The warning may be nice, but it's still, I think it's pretty cool.
- 53:44You can opt into having Python type hints become enforced basically.
- 53:49Yeah.
- 53:50What I use this for is in the asphalt.
- 53:53When I accept the configuration for a component, I use this decorator or rather an assert to
- 54:01check that the types are correct.
- 54:03So I don't, I don't raise any mysterious warning type errors or value errors further down the
- 54:09line.
- 54:09Or even worse at runtime.
- 54:11Sure.
- 54:11Okay.
- 54:12That's, that's cool.
- 54:13There is one of the features of asphalt or highlights is runtime type checking for development
- 54:19and testing to fail early when functions are called with incompatible arguments and can
- 54:24be disabled for zero overhead.
- 54:26So it sounds like, you know, you're maybe doing an import hook in development mode.
- 54:31That's handling all this for you.
- 54:33Is that right?
- 54:33Well, actually in this current version, I'm using the assert.
- 54:37So in case you didn't know when you have asserts, they are normally run without any switches
- 54:42to Python.
- 54:43But if you run Python without the debug mode, then asserts are not compiled in the bytecode.
- 54:49So just by using this switch, you can disable these potentially expensive asserts.
- 54:54Yeah.
- 54:54Okay.
- 54:55I didn't know that.
- 54:55I'm familiar with that from C and C# and other compiled languages with their pragmas
- 55:00and that type of thing.
- 55:02But I didn't realize that about Python asserts.
- 55:04Yeah.
- 55:04There's this one thing that actually, if you have this code, if under debug, and there's a
- 55:11bus of code under that block, that whole block gets omitted from the compiled code.
- 55:16If you run Python with the debug mode disabled.
- 55:20Okay.
- 55:20Yeah.
- 55:21Very cool.
- 55:21All right, Alex.
- 55:22Well, those are some cool additional projects.
- 55:24You know, I feel like the SQL A code gen, we almost could spend a whole bunch of other
- 55:28time on it.
- 55:29Another one is the AP scheduler.
- 55:31Again, could almost be its own show, but we're out of time for this one.
- 55:35So thanks so much for being here.
- 55:36Now, before you get out of here, I've got the two final questions to ask you.
- 55:39If you're going to write some Python code, what editor do you use?
- 55:43I've been looking at the different editors available.
- 55:46And so far, PyCharm wins, hands down.
- 55:50Right on.
- 55:50I'm with you there.
- 55:51So it has so many of these intelligent features and what have you that, for example, I use its
- 55:58database features to browse through my database.
- 56:01I use its refactoring features to change my code relatively safely.
- 56:06And its Docker support gives me auto-completion.
- 56:10The list goes on and on and on.
- 56:12And most of these IDs are not nearly as sophisticated.
- 56:17I agree.
- 56:18Excellent one.
- 56:18Now, notable PyPI package.
- 56:21I mean, we talked about a bunch.
- 56:22You can recommend any of these we talked about.
- 56:24You can say something else you found interesting.
- 56:27Well, I think I already mentioned Trio, but this is a difficult question, really.
- 56:33Maybe poetry.
- 56:34Okay.
- 56:34Yeah.
- 56:34Poetry.
- 56:35Yeah.
- 56:35Poetry is something that I use for my application at work.
- 56:38It's the closest thing in Fison to, say, Yarn.
- 56:42So I manage the dependencies and lock down the dependencies using poetry.
- 56:47It's quite handy for that.
- 56:50There are some issues with poetry, like when I just need to update one dependency,
- 56:56update them all, and small issues like that.
- 56:59But other than that, it's great.
- 57:01Yeah.
- 57:02It looks really great.
- 57:03I know a lot of people are loving poetry.
- 57:04It's a good recommendation there.
- 57:06All right.
- 57:07Final call to action.
- 57:07People are interested in any I.O.
- 57:09How do they get started?
- 57:11Well, there's somewhat of a tutorial there.
- 57:15I really don't have a really long tutorial on it.
- 57:18I like Trio, so I'm heavily leaning on Trio's documentation here.
- 57:22Because any I.O. has such a similar design to Trio, then a lot of Trio's manual can be
- 57:28used to draw parallels to any I.O.
- 57:31You can almost use Trio's documentation, the tutorial, to learn how any I.O. works.
- 57:37Yeah, it's highly inspired, right?
- 57:39Anything else, then you should just come to Gitter.
- 57:43I think there's a link getting help at the bottom.
- 57:46Okay.
- 57:46Yeah.
- 57:46So there's a Gitter link, and I'm usually available there.
- 57:50Great.
- 57:50Okay.
- 57:51Yeah.
- 57:51Very, very nice.
- 57:52And I'm guessing you accept contributions?
- 57:54Sure.
- 57:55Yeah.
- 57:55So, yeah.
- 57:56Let's see.
- 57:57Over here, we've got, what is that?
- 58:0033 contributors?
- 58:00So, yeah.
- 58:01Excellent.
- 58:01If people want to contribute to the project, and maybe that's code, or maybe even they
- 58:06could put together a tutorial or something like that if they're interested.
- 58:09Maybe.
- 58:10Yeah.
- 58:10Perhaps.
- 58:10Okay.
- 58:11Excellent.
- 58:11Well, thank you for all the cool libraries, and take the time to come share them with us.
- 58:16Thanks for having me.
- 58:16Yeah.
- 58:17You bet.
- 58:17Bye.
- 58:18Thanks, everyone, for listening.
- 58:19Bye.
- 58:19This has been another episode of Talk Python To Me.
- 58:23Thank you to our sponsors.
- 58:25Be sure to check out what they're offering.
- 58:26It really helps support the show.
- 58:29Listen to an episode of Compiler, an original podcast from Red Hat.
- 58:32Compiler unravels industry topics, trends, and things you've always wanted to know about
- 58:37tech through interviews with the people who know it best.
- 58:40Subscribe today by following talkpython.fm/compiler.
- 58:44Want to level up your Python?
- 58:45We have one of the largest catalogs of Python video courses over at Talk Python.
- 58:50Our content ranges from true beginners to deeply advanced topics like memory and async.
- 58:55And best of all, there's not a subscription in sight.
- 58:57Check it out for yourself.
- 58:58Be sure to subscribe to the show.
- 59:02Open your favorite podcast app and search for Python.
- 59:05We should be right at the top.
- 59:06You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 59:11and the direct RSS feed at /rss on talkpython.fm.
- 59:16We're live streaming most of our recordings these days.
- 59:19If you want to be part of the show and have your comments featured on the air,
- 59:22be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 59:28This is your host, Michael Kennedy.
- 59:29Thanks so much for listening.
- 59:30I really appreciate it.
- 59:31Now get out there and write some Python code.
- 59:33Thank you.
- 59:53Thank you.