~ubuntu-branches/ubuntu/natty/flup/natty

« back to all changes in this revision

Viewing changes to flup/server/fcgi_fork.py

  • Committer: Bazaar Package Importer
  • Author(s): Kai Hendry
  • Date: 2007-09-12 20:22:04 UTC
  • mfrom: (1.2.1 upstream) (4 gutsy)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20070912202204-fg63etr9vzaf8hea
* New upstream release
* http://www.saddi.com/software/news/archives/58-flup-1.0-released.html
* Added a note in the description that people should probably start thinking
  of moving to modwsgi.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
23
# SUCH DAMAGE.
24
24
#
25
 
# $Id: fcgi_fork.py 1968 2006-05-18 16:31:12Z asaddi $
 
25
# $Id: fcgi_fork.py 2349 2007-05-17 16:08:55Z asaddi $
26
26
 
27
27
"""
28
28
fcgi - a FastCGI/WSGI gateway.
47
47
"""
48
48
 
49
49
__author__ = 'Allan Saddi <allan@saddi.com>'
50
 
__version__ = '$Revision: 1968 $'
 
50
__version__ = '$Revision: 2349 $'
51
51
 
52
52
import os
53
53
 
54
 
from fcgi_base import BaseFCGIServer
55
 
from fcgi_base import FCGI_MAX_CONNS, FCGI_MAX_REQS, FCGI_MPXS_CONNS
56
 
from preforkserver import PreforkServer
 
54
from flup.server.fcgi_base import BaseFCGIServer, \
 
55
     FCGI_MAX_CONNS, FCGI_MAX_REQS, FCGI_MPXS_CONNS
 
56
from flup.server.preforkserver import PreforkServer
57
57
 
58
58
__all__ = ['WSGIServer']
59
59
 
97
97
            import resource
98
98
            # Attempt to glean the maximum number of connections
99
99
            # from the OS.
100
 
            maxProcs = resource.getrlimit(resource.RLIMIT_NPROC)[0]
101
 
            maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
102
 
            maxConns = min(maxConns, maxProcs)
 
100
            try:
 
101
                maxProcs = resource.getrlimit(resource.RLIMIT_NPROC)[0]
 
102
                maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
 
103
                maxConns = min(maxConns, maxProcs)
 
104
            except AttributeError:
 
105
                maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
103
106
        except ImportError:
104
107
            maxConns = 100 # Just some made up number.
105
108
        maxReqs = maxConns
162
165
        yield '</table>\n' \
163
166
              '</body></html>\n'
164
167
 
 
168
    from wsgiref import validate
 
169
    test_app = validate.validator(test_app)
165
170
    WSGIServer(test_app).run()