#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # """ This module implements a simple RPC server that can be used with the example RPC client. The client sends a 'method call' to the server, and waits for a response. The method call is a map of the form: {'method': '', 'args': { now: break t.process(now) sc = t.user_context assert isinstance(sc, SocketConnection) worked.append(sc) for w in writable: assert isinstance(w, SocketConnection) w.send_output() worked.append(w) # first, free any closed links: while dead_links: dead_links.pop().destroy() # then nuke any completed connections: closed = False while worked: sc = worked.pop() if sc.done: if sc.name in socket_connections: del socket_connections[sc.name] sc.destroy() closed = True if closed: LOG.debug("%d active connections present", len(socket_connections)) return 0 if __name__ == "__main__": sys.exit(main())