 How's it going everybody welcome back to some more Python programming videos still looking at XML RPC now We've learned how to build a server. We've learned how to use a client access servers We did our research to learn about the module. So now we're gonna take it one less step one last step further This is probably the last video I'll do on this series looking at multi-call There was some information I think presented earlier in the documentation that told us that I want to try and I want to try and hunt it down I Feel like it was in the how-to. I was showing us multi-call Yeah, see if you're writing XML RPC clients, which make a lot of small function calls You might find that the time that it takes to do all this It's pretty hefty. Thanks to like how the internet works so some of these servers allow you to batch multiple requests using multi-call and That's pretty much the the function that we're gonna be using System.multi-call and you can find more information about it. You can find more info about it in the in these pages here That apparently don't exist So never mind you might have to do some googling But anyway, we're gonna be looking at multi-call So I've got it open in the documentation for the typical Python documentation And it was described at least briefly in the Linux documentation project So what it does is it allows you to send multiple requests for Multiple functions. So let's take a look at it in code. I'll fire up idle one creating our simple server so Import simple our XML RPC server server can equal This dot this The address is going to equal local host and we'll set the port to be 8,000 Now let's define a few functions. Let's define add x and y That can return x plus y We'll define subtract X and Y I'm sure you can tell that these are pretty much the same functions that we've seen in the documentation In fact, you can pretty much see it in the back Right behind my shell here. So I'm not actually going to build the divide function I'll just go with these three. So let's register all of these to the server server register function add Subtract I do want to register our introspection functions register introspection functions And you'll notice there is another function that actually has us Register our multi-call functions, which is what we want if we want to have if our we want our server to have support For these multi-call functions and we do in this case because we want to be able to learn about them and play with them so let's turn that on and Now let's go ahead and serve forever and ever and ever Notice earlier. I was using the control space to kind of look at some of these You can take a gander at what other things this will do because I see a lot of these things aren't in the Art in the documentation. So if you I think go through the dir of server or At least the help of server You can see a little bit more information on what all of these things do. So If you've got the time I would definitely recommend kind of looking through that Doing some reading. Anyway, let's serve forever forever Cool. So now our servers on and let's fire up a client. You guys know how to do this import XML RPC lib clients can equal XML RPC lib dot server proxy and The address of the URI is going to be HTTP colon forward slash forward slash local host because that's where we're serving it Port 8000. Okay Now if I use client system list methods We'll see that we have our functions add multiply and subtract Now, let's take a look at what we can do with multi call What this is or at least how we can create it It's just creating this class with the server passed in so let's say we got this object multi-call and That'll hold what we need XML RPC lib dot multi call and We pass in the server, but in this case, it's the client Or at least what we've just named because that's our connection to the server To and it should be a capital C for multi-call There we go. Okay so now The documentation says that what we do is we have multi-call run all of these Functions that we have registered on the server. You can see they're up here in the documentation that goes to the example So let's do the exact same thing multi-call dot add Let's say three and seven multi-call dot subtract ten four and Multi-call dot multiply Two and six I guess so the way that we run this is actually calling multi-call with some parentheses like as if it were a function and The documentation the example stores it in a result because it's gonna end up returning all of these things as a list Okay, and an iterator. So what we'll do is we'll say Result is gonna equal this multi-call and I just want to see for item in results Wonder if we can print out the item Multi-pie is not okay. That's kind of fascinating it'll it'll return faults for Things that it wasn't able to successfully do Ten and six were able to run but multiply was not because I had a syntax error. I typed multiply I really didn't multiply so I Think I have to Wonder if I can remove things from the multi-call. I don't think so Hmm. No, I'm practically just experimenting at this point, but hey result in results result Wonder if I'll still get the fault. Yep. Okay, and the fault is not gonna. Let us move on to the next one huh, so know which functions that you're using here and You'll see that they've all been returned in this iterator kind of list an object So that's why I was able to get 10 from adding Three and seven I was able to get six from subtracting four from ten and I would have gotten 12 had it successfully multiplied two and six but Because I had that syntax error, and I wasn't calling the right function. It's gonna throw a fault and an error at us so That's just fine. At least we kind of know that that's what's going to happen and Be sure to call the correct functions That you know your server has so cool That's the way that multi-call works You just pretty much call the functions you need to with the multi-call object and then essentially run the object with these Forendices at the end here It's gonna return things as an iterator and you can use that in an array or list of results here And then you can get the ones that you need through a loop or anything else that you would use to access those But there they are guys That's everything that I want to cover with XML RPC from learning about it from building clients with the XML RPC lib and from actually creating servers with simple XML RPC server and a little bit of multi-call so That's the way that it goes guys. That's the way the crookie crumbles or something like that Thanks for watching. I hope you like this series. I hope you like these videos if you did like the video I mean that'd be nice. Maybe a leave me a comment. Give me something instruct your criticism how much my stuff sucks And if you're feeling generous subscribe, you know, I'd appreciate that. Thanks everybody. I'll see you again