Ejemplo n.º 1
0
    def handle_request(self):
        """Override of TCPServer.handle_request() that provides locking.

    N.B. Most of this is copied verbatim from SocketServer.py in the stdlib.
    """
        timeout = self.socket.gettimeout()
        if timeout is None:
            timeout = self.timeout
        elif self.timeout is not None:
            timeout = min(timeout, self.timeout)
        fd_sets = safe_select([self], [], [], timeout)
        if not fd_sets[0]:
            self.handle_timeout()
            return

        # After select tells us we can safely accept, guard the accept and request
        # handling with the lifecycle lock to avoid abrupt teardown mid-request.
        with self.lifecycle_lock():
            self._handle_request_noblock()
Ejemplo n.º 2
0
  def handle_request(self):
    """Override of TCPServer.handle_request() that provides locking.

    N.B. Most of this is copied verbatim from SocketServer.py in the stdlib.
    """
    timeout = self.socket.gettimeout()
    if timeout is None:
      timeout = self.timeout
    elif self.timeout is not None:
      timeout = min(timeout, self.timeout)
    fd_sets = safe_select([self], [], [], timeout)
    if not fd_sets[0]:
      self.handle_timeout()
      return

    # After select tells us we can safely accept, guard the accept and request
    # handling with the lifecycle lock to avoid abrupt teardown mid-request.
    with self.lifecycle_lock():
      self._handle_request_noblock()
Ejemplo n.º 3
0
    def handle_request(self):
        """Override of TCPServer.handle_request() that provides locking.

    Calling this method has the effect of "maybe" (if the socket does not time out first)
    accepting a request and (because we mixin in ThreadingMixIn) spawning it on a thread. It should
    always return within `min(self.timeout, socket.gettimeout())`.

    N.B. Most of this is copied verbatim from SocketServer.py in the stdlib.
    """
        timeout = self.socket.gettimeout()
        if timeout is None:
            timeout = self.timeout
        elif self.timeout is not None:
            timeout = min(timeout, self.timeout)
        fd_sets = safe_select([self], [], [], timeout)
        if not fd_sets[0]:
            self.handle_timeout()
            return

        # After select tells us we can safely accept, guard the accept and request
        # handling with the lifecycle lock to avoid abrupt teardown mid-request.
        with self.lifecycle_lock():
            self._handle_request_noblock()
Ejemplo n.º 4
0
  def handle_request(self):
    """Override of TCPServer.handle_request() that provides locking.

    Calling this method has the effect of "maybe" (if the socket does not time out first)
    accepting a request and (because we mixin in ThreadingMixIn) spawning it on a thread. It should
    always return within `min(self.timeout, socket.gettimeout())`.

    N.B. Most of this is copied verbatim from SocketServer.py in the stdlib.
    """
    timeout = self.socket.gettimeout()
    if timeout is None:
      timeout = self.timeout
    elif self.timeout is not None:
      timeout = min(timeout, self.timeout)
    fd_sets = safe_select([self], [], [], timeout)
    if not fd_sets[0]:
      self.handle_timeout()
      return

    # After select tells us we can safely accept, guard the accept and request
    # handling with the lifecycle lock to avoid abrupt teardown mid-request.
    with self.lifecycle_lock():
      self._handle_request_noblock()