码迷,mamicode.com
首页 > 其他好文 > 详细

serversocket的源码

时间:2018-09-06 00:09:46      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:finally   elf   one   cli   div   src   term   nal   RoCE   

技术分享图片

 点进去看ThreadingTCPServer中是否有__init___

class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
class ThreadingTCPServer(ThreadingMixIn, TCPServer): pass
#
ThreadingTCPServer 什么也没干,只继承了两个类,去自己的父类里找,从左到右

 

class ThreadingMixIn:
    """Mix-in class to handle each request in a new thread."""

    # Decides how threads will act upon termination of the
    # main process
    daemon_threads = False
   #方法一
    def process_request_thread(self, request, client_address):
        """Same as in BaseServer but as a thread.

        In addition, exception handling is done here.

        """
        try:
            self.finish_request(request, client_address)
        except Exception:
            self.handle_error(request, client_address)
        finally:
            self.shutdown_request(request)
   #方法二
    def process_request(self, request, client_address):
        """Start a new thread to process the request."""
        t = threading.Thread(target = self.process_request_thread,
                             args = (request, client_address))
        t.daemon = self.daemon_threads
        t.start()

 

serversocket的源码

标签:finally   elf   one   cli   div   src   term   nal   RoCE   

原文地址:https://www.cnblogs.com/2275114213com/p/9594880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!