Exemplo n.º 1
0
 def set_handle(self, handle):
     BaseServer.set_handle(self, handle)
     # make SSL work:
     if self.ssl_enabled:
         self._handle = self.wrap_socket_and_handle
     else:
         self._handle = self.handle
Exemplo n.º 2
0
 def set_listener(self, listener):
     BaseServer.set_listener(self, listener)
     try:
         if sys.version_info[0] == 2:
             self.socket = self.socket._sock
     except AttributeError:
         pass
 def pre_start(self):
     BaseServer.pre_start(self)
     # make SSL work:
     if self.ssl_enabled:
         self._handle = self.wrap_socket_and_handle
     else:
         self._handle = self.handle
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     device = kwargs.pop('device')
     self.link_name = kwargs.pop('url')
     e_kwargs = dict(baudrate=kwargs.pop('baudrate', None),
                     newline=kwargs.pop('newline', None))
     BaseServer.__init__(self, None, *args, **kwargs)
     EmulatorServerMixin.__init__(self, device, **e_kwargs)
Exemplo n.º 5
0
 def set_handle(self, handle):
     BaseServer.set_handle(self, handle)
     # make SSL work:
     if self.ssl_enabled:
         self._handle = self.wrap_socket_and_handle
     else:
         self._handle = self.handle
Exemplo n.º 6
0
 def pre_start(self):
     BaseServer.pre_start(self)
     # make SSL work:
     if self.ssl_enabled:
         self._handle = self.wrap_socket_and_handle
     else:
         self._handle = self.handle
 def __init__(self,
              listener,
              handle=None,
              backlog=None,
              spawn='default',
              **ssl_args):
     if ssl_args:
         ssl_args.setdefault('server_side', True)
         try:
             from gevent.ssl import wrap_socket
         except ImportError:
             wrap_socket = _import_sslold_wrap_socket()
             if wrap_socket is None:
                 raise
         self.wrap_socket = wrap_socket
         self.ssl_args = ssl_args
         self.ssl_enabled = True
     else:
         self.ssl_enabled = False
     BaseServer.__init__(self,
                         listener,
                         handle=handle,
                         backlog=backlog,
                         spawn=spawn)
     self.delay = self.min_delay
     self._accept_event = None
     self._start_accepting_timer = None
Exemplo n.º 8
0
 def __init__(self,
              listener,
              handle=None,
              backlog=None,
              spawn='default',
              **ssl_args):
     BaseServer.__init__(self, listener, handle=handle, spawn=spawn)
     try:
         if ssl_args:
             ssl_args.setdefault('server_side', True)
             if 'ssl_context' in ssl_args:
                 ssl_context = ssl_args.pop('ssl_context')
                 self.wrap_socket = ssl_context.wrap_socket
                 self.ssl_args = ssl_args
             else:
                 from gevent.ssl import wrap_socket
                 self.wrap_socket = wrap_socket
                 self.ssl_args = ssl_args
         else:
             self.ssl_args = None
         if backlog is not None:
             if hasattr(self, 'socket'):
                 raise TypeError(
                     'backlog must be None when a socket instance is passed'
                 )
             self.backlog = backlog
     except:
         self.close()
         raise
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     device = kwargs.pop('device')
     self.link_name = kwargs.pop('url')
     e_kwargs = dict(baudrate=kwargs.pop('baudrate', None),
                     newline=kwargs.pop('newline', None))
     BaseServer.__init__(self, None, *args, **kwargs)
     EmulatorServerMixin.__init__(self, device, **e_kwargs)
Exemplo n.º 10
0
 def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args):
     BaseServer.__init__(self, listener, handle=handle, spawn=spawn)
     try:
         if ssl_args:
             ssl_args.setdefault('server_side', True)
             if 'ssl_context' in ssl_args:
                 ssl_context = ssl_args.pop('ssl_context')
                 self.wrap_socket = ssl_context.wrap_socket
Exemplo n.º 11
0
 def kill(self):
     try:
         BaseServer.kill(self)
     finally:
         self.__dict__.pop('_handle', None)
         pool = getattr(self, 'pool', None)
         if pool is not None:
             pool._semaphore.unlink(self._start_accepting_if_started)
Exemplo n.º 12
0
 def kill(self):
     try:
         BaseServer.kill(self)
     finally:
         self.__dict__.pop('_handle', None)
         pool = getattr(self, 'pool', None)
         if pool is not None:
             pool._semaphore.unlink(self._start_accepting_if_started)
Exemplo n.º 13
0
    def __init__(self, host, port, handle=None, backlog=None, spawn='default', **ssl_args):
        listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        listener.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
        listener.bind((host, int(port)))

        BaseServer.__init__(self, listener, handle=handle, backlog=backlog, spawn=spawn)
        self.delay = self.min_delay
        self._recv_event = None
        self._start_receving_timer = None
Exemplo n.º 14
0
 def __init__(self,
              listener,
              handle=None,
              backlog=None,
              spawn='default',
              **ssl_args):
     BaseServer.__init__(self,
                         listener,
                         handle=handle,
                         backlog=backlog,
                         spawn=spawn)
     self.delay = self.min_delay
     self._recv_event = None
     self._start_receving_timer = None
Exemplo n.º 15
0
 def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args):
     if ssl_args:
         for arg in ssl_args:
             if arg not in self._allowed_ssl_args:
                 raise TypeError('StreamServer.__init__() got an unexpected keyword argument %r' % arg)
         from gevent.ssl import wrap_socket
         self.wrap_socket = wrap_socket
         self.ssl_args = ssl_args
         self.ssl_enabled = True
     else:
         self.ssl_enabled = False
     BaseServer.__init__(self, listener, handle=handle, backlog=backlog, spawn=spawn)
     self.delay = self.min_delay
     self._accept_event = None
     self._start_accepting_timer = None
Exemplo n.º 16
0
 def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args):
     BaseServer.__init__(self, listener, handle=handle, spawn=spawn)
     try:
         if ssl_args:
             ssl_args.setdefault('server_side', True)
             from gevent.ssl import wrap_socket
             self.wrap_socket = wrap_socket
             self.ssl_args = ssl_args
         else:
             self.ssl_args = None
         if backlog is not None:
             if hasattr(self, 'socket'):
                 raise TypeError('backlog must be None when a socket instance is passed')
             self.backlog = backlog
     except:
         self.close()
         raise
Exemplo n.º 17
0
 def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args):
     if ssl_args:
         ssl_args.setdefault('server_side', True)
         try:
             from gevent.ssl import wrap_socket
         except ImportError:
             wrap_socket = _import_sslold_wrap_socket()
             if wrap_socket is None:
                 raise
         self.wrap_socket = wrap_socket
         self.ssl_args = ssl_args
         self.ssl_enabled = True
     else:
         self.ssl_enabled = False
     BaseServer.__init__(self, listener, handle=handle, backlog=backlog, spawn=spawn)
     self.delay = self.min_delay
     self._accept_event = None
     self._start_accepting_timer = None
Exemplo n.º 18
0
 def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args):
     if ssl_args:
         for arg in ssl_args:
             if arg not in self._allowed_ssl_args:
                 raise TypeError('StreamServer.__init__() got an unexpected keyword argument %r' % arg)
         try:
             from gevent.ssl import wrap_socket
         except ImportError:
             wrap_socket = _import_sslold_wrap_socket()
             if wrap_socket is None:
                 raise
         self.wrap_socket = wrap_socket
         self.ssl_args = ssl_args
         self.ssl_enabled = True
     else:
         self.ssl_enabled = False
     BaseServer.__init__(self, listener, handle=handle, backlog=backlog, spawn=spawn)
     self.delay = self.min_delay
     self._accept_event = None
     self._start_accepting_timer = None
Exemplo n.º 19
0
 def set_spawn(self, spawn):
     BaseServer.set_spawn(self, spawn)
     if self.pool is not None:
         self.pool._semaphore.rawlink(self._start_accepting_if_started)
Exemplo n.º 20
0
 def set_listener(self, listener):
     BaseServer.set_listener(self, listener)
Exemplo n.º 21
0
 def __init__(self, listener, handle=None, backlog=None, spawn='default', default_response_headers='default'):
     BaseServer.__init__(self, listener, handle=handle, backlog=backlog, spawn=spawn)
     self.http = None
     if default_response_headers != 'default':
         self.default_response_headers = default_response_headers
Exemplo n.º 22
0
 def set_listener(self, listener, backlog=None):
     BaseServer.set_listener(self, listener, backlog=backlog)
     try:
         self.socket = self.socket._sock
     except AttributeError:
         pass
Exemplo n.º 23
0
 def __init__(self, *args, **kwargs):
     BaseServer.__init__(self, *args, **kwargs)
     from gevent.lock import Semaphore
     self._writelock = Semaphore()
Exemplo n.º 24
0
 def set_handle(self, handle):
     BaseServer.set_handle(self, handle)
     self._handle = handle
Exemplo n.º 25
0
 def set_spawn(self, spawn):
     BaseServer.set_spawn(self, spawn)
     if self.pool is not None:
         self.pool._semaphore.rawlink(self._start_accepting_if_started)
Exemplo n.º 26
0
 def set_listener(self, listener, backlog=None):
     BaseServer.set_listener(self, listener, backlog=backlog)
     try:
         self.socket = self.socket._sock
     except AttributeError:
         pass
Exemplo n.º 27
0
 def set_spawn(self, spawn):
     BaseServer.set_spawn(self, spawn)
     if self.pool is not None:
         self.pool._semaphore.rawlink(self._start_receiving)
Exemplo n.º 28
0
 def set_handle(self, handle):
     BaseServer.set_handle(self, handle)
     self._handle = self.handle
Exemplo n.º 29
0
 def set_spawn(self, spawn):
     BaseServer.set_spawn(self, spawn)
     if self.pool is not None:
         self.pool._semaphore.rawlink(self._start_receiving)
Exemplo n.º 30
0
 def __init__(self, *args, **kwargs):
     BaseServer.__init__(self, *args, **kwargs)
     from gevent.lock import Semaphore
     self._writelock = Semaphore()
Exemplo n.º 31
0
 def __init__(self, *args, **kwargs):
     # The raw (non-gevent) socket, if possible
     self._socket = None
     BaseServer.__init__(self, *args, **kwargs)
     from gevent.lock import Semaphore
     self._writelock = Semaphore()
Exemplo n.º 32
0
 def set_listener(self, listener):
     BaseServer.set_listener(self, listener)
     try:
         self.socket = self.socket._sock
     except AttributeError:
         pass
Exemplo n.º 33
0
 def __init__(self, *args, **kwargs):
     # The raw (non-gevent) socket, if possible
     self._socket = None
     BaseServer.__init__(self, *args, **kwargs)
     from gevent.lock import Semaphore
     self._writelock = Semaphore()
Exemplo n.º 34
0
 def set_listener(self, listener):
     BaseServer.set_listener(self, listener)
     try:
         self.socket = self.socket._sock
     except AttributeError:
         pass
Exemplo n.º 35
0
 def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args):
     BaseServer.__init__(self, listener, handle=handle, backlog=backlog, spawn=spawn)
     self.delay = self.min_delay
     self._recv_event = None
     self._start_receving_timer = None