MCPcopy Create free account
hub / github.com/pyload/pyload / stop

Method stop

module/lib/wsgiserver/__init__.py:1712–1748  ·  view source on GitHub ↗

Gracefully shutdown a server that is serving forever.

(self)

Source from the content-addressed store, hash-verified

1710 "interrupt the server.")
1711
1712 def stop(self):
1713 """Gracefully shutdown a server that is serving forever."""
1714 self.ready = False
1715
1716 sock = getattr(self, "socket", None)
1717 if sock:
1718 if not isinstance(self.bind_addr, basestring):
1719 # Touch our own socket to make accept() return immediately.
1720 try:
1721 host, port = sock.getsockname()[:2]
1722 except socket.error, x:
1723 if x.args[0] not in socket_errors_to_ignore:
1724 raise
1725 else:
1726 # Note that we're explicitly NOT using AI_PASSIVE,
1727 # here, because we want an actual IP to touch.
1728 # localhost won't work if we've bound to a public IP,
1729 # but it will if we bound to '0.0.0.0' (INADDR_ANY).
1730 for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC,
1731 socket.SOCK_STREAM):
1732 af, socktype, proto, canonname, sa = res
1733 s = None
1734 try:
1735 s = socket.socket(af, socktype, proto)
1736 # See http://groups.google.com/group/cherrypy-users/
1737 # browse_frm/thread/bbfe5eb39c904fe0
1738 s.settimeout(1.0)
1739 s.connect((host, port))
1740 s.close()
1741 except socket.error:
1742 if s:
1743 s.close()
1744 if hasattr(sock, "close"):
1745 sock.close()
1746 self.socket = None
1747
1748 self.requests.stop(self.shutdown_timeout)
1749
1750 def populate_ssl_environ(self):
1751 """Create WSGI environ entries to be merged into each request."""

Callers 2

runMethod · 0.95
_set_interruptMethod · 0.95

Calls 2

closeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected