zoukankan      html  css  js  c++  java
  • autoreload 线程 进程管理 并发的处理方法

    Django  autoreload  

    https://github.com/django/django/blob/9386586f31b8a0bccf59a1bff647cd829d4e79aa/django/utils/autoreload.py


    django/core/management/commands/runserver.py ---> handler = self.get_handler(*args, **options)
    run(self.addr, int(self.port), handler,
    ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)----> django/dispatch/dispatcher.py ---> def init(self, providing_args=None, use_caching=False):
    """
    Create a new signal.
    providing_args
    A list of the arguments this signal can pass along in a send() call.
    """
    self.receivers = []
    if providing_args is None:
    providing_args = []
    self.providing_args = set(providing_args)
    self.lock = threading.Lock()
    self.use_caching = use_caching

    https://github.com/python/cpython/blob/master/Lib/socketserver.py


    For request-based servers (including socket-based):
    - how to handle multiple requests:
    - synchronous (one request is handled at a time)
    - forking (each request is handled by a new process)
    - threading (each request is handled by a new thread)


    # poll/select have the advantage of not requiring any extra file descriptor,
    # contrarily to epoll/kqueue (also, they require a single syscall).


    Another approach to handling multiple simultaneous requests in an
    environment that supports neither threads nor fork (or where these are
    too expensive or inappropriate for the service) is to maintain an
    explicit table of partially finished requests and to use a selector to
    decide which request to work on next (or whether to handle a new
    incoming request). This is particularly important for stream services
    where each client can potentially be connected for a long time (if
    threads or subprocesses cannot be used).

  • 相关阅读:
    js闭包
    python切片 []取值操作符
    python with语句
    python鸭子类型(duck type)
    python编码规范
    python @property使用详解
    python __slots__使用详解
    Python面向对象编程
    ifconfig命令详解
    5、Cocos2dx 3.0游戏开发找小三之測试例子简单介绍及小结
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8985192.html
Copyright © 2011-2022 走看看