A long-running application server will be reading requests from some kind of queue and formulating responses to those requests. In many cases, we leverage the HTTP protocol and build application servers into a web server framework. See Chapter 13, Transmitting and Sharing Objects, for details on how to implement RESTful web services following the Web Server Gateway Interface (WSGI) design pattern.
A desktop GUI application has a lot of features in common with a server. It reads events from a queue that includes mouse and keyboard actions. It handles each event and gives some kind of GUI response. In some cases, the response may be a small update to a text widget. In other cases, a file might get opened or closed, and the state of menu items may change.
In both cases, the central feature of the application is a loop that runs forever, handling...