Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)

        def server_class(opts, args):
    
    if opts.childtype == PROCESS:
        from plib.stdlib.comm._processwrapper import ProcessWrapper
        from plib.stdlib.classes import SigChldMixin
        from plib.stdlib.decotools import wraps_class
        
        @wraps_class(DemoServer)
        class _Server(SigChldMixin, DemoServer):
            
            wrapper_class = ProcessWrapper
            
            def child_sig_handler(self, sig, frame=None):
                print "Child exit signal received by handler"
                SigChldMixin.child_sig_handler(self, sig, frame)
            
            def sig_handler(self, sig):
                if sig == signal.SIGCHLD:
                    print "Child exit signal received through pipe"
                    self.reap_children()
                else:
                    DemoServer.sig_handler(self, sig)
            
            def setup_handlers(self):
                DemoServer.setup_handlers(self)
                if hasattr(signal, 'SIGCHLD'):
                    if self.use_pipe:
                        self.pipe.track_signal(signal.SIGCHLD, reset=True)
                    else:
                        self.setup_child_sig_handler()
            
            def setup_child(self, child):
                self.track_child(child)
            
            def check_child(self, child):
                return child.check()
            
            def end_child(self, child):
                child.end()
            
            def cleanup_request(self, request, client_address):
                # Only the child process needs the request open now
                self.close_request(request)
    
    elif opts.childtype == THREAD:
        from plib.stdlib.comm._threadwrapper import ThreadWrapper
        from plib.stdlib.decotools import wraps_class
        
        @wraps_class(DemoServer)
        class _Server(DemoServer):
            
            wrapper_class = ThreadWrapper
            
            def check_child(self, child):
                return child.check()
            
            def end_child(self, child):
                child.end()
    
    else:
        _Server = DemoServer
    
    return partial(_Server,
                   ("localhost", int(args.portnum)),
                   DemoRequestHandler,
                   opts.use_pipe, opts.test_race)
        


src/p/l/plib.stdlib-0.9.11/examples/server/clientserver.py   plib.stdlib(Download)
    from plib.stdlib.options import parse_options
 
    from server import server_class, server_optlist, server_arglist
 
    optlist = server_optlist + (
    opts, args = parse_options(optlist, arglist)
 
    run_clientserver(server_class(opts, args), opts.use_socketpair, args.portnum)