Пример #1
0
 def __init__(self,
              application,
              map=None,
              _start=True,      # test shim
              _sock=None,       # test shim
              _dispatcher=None, # test shim
              adj=None,         # adjustments
              **kw
              ):
     if adj is None:
         adj = Adjustments(**kw)
     self.application = application
     self.adj = adj
     self.trigger = trigger.trigger(map)
     if _dispatcher is None:
         _dispatcher = ThreadedTaskDispatcher()
         _dispatcher.set_thread_count(self.adj.threads)
     self.task_dispatcher = _dispatcher
     self.asyncore.dispatcher.__init__(self, _sock, map=map)
     if _sock is None:
         self.create_socket(self.family, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind_server_socket()
     self.effective_host, self.effective_port = self.getsockname()
     self.server_name = self.get_server_name(self.adj.host)
     self.active_channels = {}
     if _start:
         self.accept_connections()
Пример #2
0
 def __init__(
         self,
         application,
         map=None,
         _start=True,  # test shim
         _sock=None,  # test shim
         _dispatcher=None,  # test shim
         adj=None,  # adjustments
         **kw):
     if adj is None:
         adj = Adjustments(**kw)
     if map is None:
         # use a nonglobal socket map by default to hopefully prevent
         # conflicts with apps and libs that use the asyncore global socket
         # map ala https://github.com/Pylons/waitress/issues/63
         map = {}
     self.application = application
     self.adj = adj
     self.trigger = trigger.trigger(map)
     if _dispatcher is None:
         _dispatcher = ThreadedTaskDispatcher()
         _dispatcher.set_thread_count(self.adj.threads)
     self.task_dispatcher = _dispatcher
     self.asyncore.dispatcher.__init__(self, _sock, map=map)
     if _sock is None:
         self.create_socket(self.family, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind_server_socket()
     self.effective_host, self.effective_port = self.getsockname()
     self.server_name = self.get_server_name(self.adj.host)
     self.active_channels = {}
     if _start:
         self.accept_connections()
Пример #3
0
 def __init__(self,
              application,
              map=None,
              _start=True,      # test shim
              _sock=None,       # test shim
              _dispatcher=None, # test shim
              adj=None,         # adjustments
              **kw
              ):
     if adj is None:
         adj = Adjustments(**kw)
     if map is None:
         # use a nonglobal socket map by default to hopefully prevent
         # conflicts with apps and libs that use the asyncore global socket
         # map ala https://github.com/Pylons/waitress/issues/63
         map = {}
     self.application = application
     self.adj = adj
     self.trigger = trigger.trigger(map)
     if _dispatcher is None:
         _dispatcher = ThreadedTaskDispatcher()
         _dispatcher.set_thread_count(self.adj.threads)
     self.task_dispatcher = _dispatcher
     self.asyncore.dispatcher.__init__(self, _sock, map=map)
     if _sock is None:
         self.create_socket(self.family, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind_server_socket()
     self.effective_host, self.effective_port = self.getsockname()
     self.server_name = self.get_server_name(self.adj.host)
     self.active_channels = {}
     if _start:
         self.accept_connections()
Пример #4
0
    def __init__(self,
                 application,
                 map=None,
                 _start=True, # test shim
                 _sock=None,  # test shim
                 _dispatcher=None, # test shim
                 **kw # adjustments
                 ):

        self.application = application
        self.adj = Adjustments(**kw)
        self.trigger = trigger.trigger(map)
        if _dispatcher is None:
            _dispatcher = ThreadedTaskDispatcher()
            _dispatcher.set_thread_count(self.adj.threads)
        self.task_dispatcher = _dispatcher
        self.asyncore.dispatcher.__init__(self, _sock, map=map)
        if _sock is None:
            try:
                info = socket.getaddrinfo( self.adj.host, self.adj.port, socket.AF_UNSPEC,
                                           socket.SOCK_STREAM, 0, socket.AI_PASSIVE)
                if info:
                    self.create_socket(info[0][0], socket.SOCK_STREAM)
            except socket.gaierror:
                self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
                
        self.set_reuse_addr()
        self.bind((self.adj.host, self.adj.port))
        # Ignore scope & flow ID if returned for IPv6 sockets
        self.effective_host, self.effective_port = self.getsockname()[:2]
        self.server_name = self.get_server_name(self.adj.host)
        self.active_channels = {}
        if _start:
            self.accept_connections()
Пример #5
0
    def __init__(self,
                 application,
                 map=None,
                 _start=True,      # test shim
                 _sock=None,       # test shim
                 dispatcher=None,  # dispatcher
                 adj=None,         # adjustments
                 sockinfo=None,    # opaque object
                 bind_socket=True,
                 **kw
                 ):
        if adj is None:
            adj = Adjustments(**kw)
        if map is None:
            # use a nonglobal socket map by default to hopefully prevent
            # conflicts with apps and libs that use the wasyncore global socket
            # map ala https://github.com/Pylons/waitress/issues/63
            map = {}
        if sockinfo is None:
            sockinfo = adj.listen[0]

        self.sockinfo = sockinfo
        self.family = sockinfo[0]
        self.socktype = sockinfo[1]
        self.application = application
        self.adj = adj
        self.trigger = trigger.trigger(map)
        if dispatcher is None:
            dispatcher = ThreadedTaskDispatcher()
            dispatcher.set_thread_count(self.adj.threads)

        self.task_dispatcher = dispatcher
        self.asyncore.dispatcher.__init__(self, _sock, map=map)
        if _sock is None:
            self.create_socket(self.family, self.socktype)
            if self.family == socket.AF_INET6: # pragma: nocover
                self.socket.setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 1)

        self.set_reuse_addr()

        if bind_socket:
            self.bind_server_socket()

        self.effective_host, self.effective_port = self.getsockname()
        self.server_name = self.get_server_name(self.effective_host)
        self.active_channels = {}
        if _start:
            self.accept_connections()
Пример #6
0
    def __init__(
            self,
            application,
            map=None,
            _start=True,  # test shim
            _sock=None,  # test shim
            _dispatcher=None,  # test shim
            **kw  # adjustments
    ):

        self.application = application
        self.adj = Adjustments(**kw)
        self.trigger = trigger.trigger(map)
        if _dispatcher is None:
            _dispatcher = ThreadedTaskDispatcher()
            _dispatcher.set_thread_count(self.adj.threads)
        self.task_dispatcher = _dispatcher
        self.asyncore.dispatcher.__init__(self, _sock, map=map)
        if _sock is None:
            try:
                info = socket.getaddrinfo(self.adj.host, self.adj.port,
                                          socket.AF_UNSPEC, socket.SOCK_STREAM,
                                          0, socket.AI_PASSIVE)
                if info:
                    self.create_socket(info[0][0], socket.SOCK_STREAM)
            except socket.gaierror:
                self.create_socket(socket.AF_INET, socket.SOCK_STREAM)

        self.set_reuse_addr()
        self.bind((self.adj.host, self.adj.port))
        # Ignore scope & flow ID if returned for IPv6 sockets
        self.effective_host, self.effective_port = self.getsockname()[:2]
        self.server_name = self.get_server_name(self.adj.host)
        self.active_channels = {}
        if _start:
            self.accept_connections()
Пример #7
0
    def __init__(
        self,
        application,
        map=None,
        _start=True,  # test shim
        _sock=None,  # test shim
        dispatcher=None,  # dispatcher
        adj=None,  # adjustments
        sockinfo=None,  # opaque object
        bind_socket=True,
        **kw
    ):
        if adj is None:
            adj = Adjustments(**kw)

        if adj.trusted_proxy or adj.clear_untrusted_proxy_headers:
            # wrap the application to deal with proxy headers
            # we wrap it here because webtest subclasses the TcpWSGIServer
            # directly and thus doesn't run any code that's in create_server
            application = proxy_headers_middleware(
                application,
                trusted_proxy=adj.trusted_proxy,
                trusted_proxy_count=adj.trusted_proxy_count,
                trusted_proxy_headers=adj.trusted_proxy_headers,
                clear_untrusted=adj.clear_untrusted_proxy_headers,
                log_untrusted=adj.log_untrusted_proxy_headers,
                logger=self.logger,
            )

        if map is None:
            # use a nonglobal socket map by default to hopefully prevent
            # conflicts with apps and libs that use the wasyncore global socket
            # map ala https://github.com/Pylons/waitress/issues/63
            map = {}
        if sockinfo is None:
            sockinfo = adj.listen[0]

        self.sockinfo = sockinfo
        self.family = sockinfo[0]
        self.socktype = sockinfo[1]
        self.application = application
        self.adj = adj
        self.trigger = trigger.trigger(map)
        if dispatcher is None:
            dispatcher = ThreadedTaskDispatcher()
            dispatcher.set_thread_count(self.adj.threads)

        self.task_dispatcher = dispatcher
        self.asyncore.dispatcher.__init__(self, _sock, map=map)
        if _sock is None:
            self.create_socket(self.family, self.socktype)
            if self.family == socket.AF_INET6:  # pragma: nocover
                self.socket.setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 1)

        self.set_reuse_addr()

        if bind_socket:
            self.bind_server_socket()

        self.effective_host, self.effective_port = self.getsockname()
        self.server_name = self.get_server_name(self.effective_host)
        self.active_channels = {}
        if _start:
            self.accept_connections()
Пример #8
0
 def _makeOne(self, map):
     from waitress.trigger import trigger
     return trigger(map)
Пример #9
0
        def _makeOne(self, map):
            from waitress.trigger import trigger

            self.inst = trigger(map)
            return self.inst
Пример #10
0
 def _makeOne(self, map):
     from waitress.trigger import trigger
     self.inst = trigger(map)
     return self.inst
Пример #11
0
 def _makeOne(self, map):
     from waitress.trigger import trigger
     return trigger(map)