def cleanShutdown(): # Stop accepting new connections connections.socket_lock.acquire() try: _linda_server.server_disconnect() connections.sockets = [ s for s in connections.sockets if s.type != "bound" ] finally: connections.socket_lock.release() # Disappear from zeroconf network if options.mdns and not options.disable_mdns: import mdns mdns.disconnect() # Close client connections connections.socket_lock.acquire() try: for t in threads.values(): t.close() for p in processes.values(): p.close() finally: connections.socket_lock.release() # garbage collect all tuplespaces local_ts.forceGarbage() connections.close = True connections.socket_lock.acquire() try: for s in connections.sockets: s.close() finally: connections.socket_lock.release() if _linda_server.use_types: emptyTypeCache() emptyIsoCache() gc.collect( ) # Run garbage collection so libminimal doesn't produce spurious warnings. _linda_server.finalise() sys.exit()
def cleanShutdown(): # Stop accepting new connections connections.socket_lock.acquire() try: _linda_server.server_disconnect() connections.sockets = [s for s in connections.sockets if s.type != "bound"] finally: connections.socket_lock.release() # Disappear from zeroconf network if options.mdns and not options.disable_mdns: import mdns mdns.disconnect() # Close client connections connections.socket_lock.acquire() try: for t in threads.values(): t.close() for p in processes.values(): p.close() finally: connections.socket_lock.release() # garbage collect all tuplespaces local_ts.forceGarbage() connections.close = True connections.socket_lock.acquire() try: for s in connections.sockets: s.close() finally: connections.socket_lock.release() if _linda_server.use_types: emptyTypeCache() emptyIsoCache() gc.collect() # Run garbage collection so libminimal doesn't produce spurious warnings. _linda_server.finalise() sys.exit()
#!/usr/bin/python import sys import _linda_server if __name__ == "__main__": if not _linda_server.serve(): sys.exit(-1) sd = _linda_server.accept() m = _linda_server.recv(sd) print m if m[0] == "OUT": _linda_server.send(sd, ("DONE", )) _linda_server.server_disconnect()