Coverage for manila/wsgi/eventlet_server.py: 0%

12 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright 2010 United States Government as represented by the 

2# Administrator of the National Aeronautics and Space Administration. 

3# Copyright 2010 OpenStack LLC. 

4# All Rights Reserved. 

5# 

6# Licensed under the Apache License, Version 2.0 (the "License"); you may 

7# not use this file except in compliance with the License. You may obtain 

8# a copy of the License at 

9# 

10# http://www.apache.org/licenses/LICENSE-2.0 

11# 

12# Unless required by applicable law or agreed to in writing, software 

13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

15# License for the specific language governing permissions and limitations 

16# under the License. 

17 

18"""Utility methods for working with WSGI servers.""" 

19 

20import socket 

21 

22from oslo_config import cfg 

23from oslo_service import wsgi 

24from oslo_utils import netutils 

25 

26socket_opts = [ 

27 cfg.BoolOpt('tcp_keepalive', 

28 default=True, 

29 help="Sets the value of TCP_KEEPALIVE (True/False) for each " 

30 "server socket."), 

31 cfg.IntOpt('tcp_keepalive_interval', 

32 help="Sets the value of TCP_KEEPINTVL in seconds for each " 

33 "server socket. Not supported on OS X."), 

34 cfg.IntOpt('tcp_keepalive_count', 

35 help="Sets the value of TCP_KEEPCNT for each " 

36 "server socket. Not supported on OS X."), 

37] 

38 

39CONF = cfg.CONF 

40CONF.register_opts(socket_opts) 

41 

42 

43class Server(wsgi.Server): 

44 """Server class to manage a WSGI server, serving a WSGI application.""" 

45 

46 def _set_socket_opts(self, _socket): 

47 _socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 

48 

49 # NOTE(praneshp): Call set_tcp_keepalive in oslo to set 

50 # tcp keepalive parameters. Sockets can hang around forever 

51 # without keepalive 

52 netutils.set_tcp_keepalive( 

53 _socket, 

54 self.conf.tcp_keepalive, 

55 self.conf.tcp_keepidle, 

56 self.conf.tcp_keepalive_count, 

57 self.conf.tcp_keepalive_interval, 

58 ) 

59 return _socket