Summary

We have looked at transmitting and sharing objects using RESTful web services. RESTful web services via Flask are one way to do this. The multiprocessing module embodies a radically different solution to the same problem. Both of these architectures provide for communicating a representation of an object's state. In the case of multiprocessing, pickle is used to represent the state. In the case of building RESTful web services, we have to choose the representation(s) used. In the examples used here, we focused on JSON, because it's widely used and has a simple implementation.

RESTful web services often use a framework to simplify the code required for the standard features of HTTP request and response processing. In the examples, we identified four steps: parsing, evaluating, logging, and responding. The Flask framework provides a simple, extensible framework for this. Because WSGI applications have a simple, standardized API, we can easily a variety of frameworks for web applications. In this chapter, we looked at using Flask for implementing RESTful services.

We also looked at using multiprocessing to enqueue and dequeue messages from shared queues. This works nicely for passing objects from process to process. The beauty of using interprocess message queues is that we can avoid the locking problems associated with concurrent updates to objects shared by multiple threads.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset