当前位置: 首页>>代码示例>>Python>>正文


Python fcgi.WSGIServer类代码示例

本文整理汇总了Python中flup.server.fcgi.WSGIServer的典型用法代码示例。如果您正苦于以下问题:Python WSGIServer类的具体用法?Python WSGIServer怎么用?Python WSGIServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WSGIServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FlupFCGIServer

class FlupFCGIServer(object):
    """Adapter for a flup.server.fcgi.WSGIServer."""
    
    def __init__(self, *args, **kwargs):
        from flup.server.fcgi import WSGIServer
        self.fcgiserver = WSGIServer(*args, **kwargs)
        # TODO: report this bug upstream to flup.
        # If we don't set _oldSIGs on Windows, we get:
        #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
        #   line 108, in run
        #     self._restoreSignalHandlers()
        #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
        #   line 156, in _restoreSignalHandlers
        #     for signum,handler in self._oldSIGs:
        #   AttributeError: 'WSGIServer' object has no attribute '_oldSIGs'
        self.fcgiserver._oldSIGs = []
        self.ready = False
    
    def start(self):
        """Start the FCGI server."""
        self.ready = True
        self.fcgiserver.run()
    
    def stop(self):
        """Stop the HTTP server."""
        self.ready = False
        # Forcibly stop the fcgi server main event loop.
        self.fcgiserver._keepGoing = False
        # Force all worker threads to die off.
        self.fcgiserver._threadPool.maxSpare = 0
开发者ID:fmcingvale,项目名称:cherrypy_gae,代码行数:30,代码来源:servers.py

示例2: _runFlup

def _runFlup(app, config, mode):
    """Run WsgiDAV using flup.server.fcgi, if Flup is installed."""
    try:
        # http://trac.saddi.com/flup/wiki/FlupServers
        if mode == "flup-fcgi" or "runfcgi":
            from flup.server.fcgi import WSGIServer, __version__ as flupver
        elif mode == "flup-fcgi_fork":
            from flup.server.fcgi_fork import WSGIServer, __version__ as flupver
        else:
            raise ValueError    

        if config["verbose"] >= 2:
            print "Running WsgiDAV/%s %s/%s..." % (__version__,
                                                   WSGIServer.__module__,
                                                   flupver)
        server = WSGIServer(app,
                            bindAddress=(config["host"], config["port"]),
#                            bindAddress=("127.0.0.1", 8001),
#                            debug=True,
                            )
        server.run()
    except ImportError, e:
        if config["verbose"] >= 1:
            print "Could not import flup.server.fcgi", e
        return False
开发者ID:GregoireGalland,项目名称:seafdav,代码行数:25,代码来源:run_server.py

示例3: main

def main():
    app = create_app()

    log_fmt = logging.Formatter("[%(asctime)s] %(module)s "
                                "%(levelname)s %(message)s")

    suggestion_log_path = os.path.join(app.instance_path, 'database.log')
    suggestion_handler = logging.FileHandler(suggestion_log_path)
    suggestion_handler.setFormatter(log_fmt)
    database.log.addHandler(suggestion_handler)

    import sys
    if len(sys.argv) > 1:
        cmd = sys.argv[1]
    else:
        cmd = 'runserver'

    if cmd == 'runserver':
        app.run(debug=True)
    elif cmd == 'shell':
        from code import interact
        with app.test_request_context():
            interact(local={'app': app})
    elif cmd == 'fastcgi':
        from flup.server.fcgi import WSGIServer
        error_log_path = os.path.join(app.instance_path, 'error.log')
        error_handler = logging.FileHandler(error_log_path)
        error_handler.setFormatter(log_fmt)
        error_handler.setLevel(logging.ERROR)
        logging.getLogger().addHandler(error_handler)
        sock_path = os.path.join(app.instance_path, 'fcgi.sock')
        server = WSGIServer(app, bindAddress=sock_path, umask=0)
        server.run()
开发者ID:piatra,项目名称:agenda-politicieni,代码行数:33,代码来源:agenda.py

示例4: FlupSCGIServer

class FlupSCGIServer(object):
    """Adapter for a flup.server.scgi.WSGIServer."""
    
    def __init__(self, *args, **kwargs):
        self.args = args
        self.kwargs = kwargs
        self.ready = False
    
    def start(self):
        """Start the SCGI server."""
        # We have to instantiate the server class here because its __init__
        # starts a threadpool. If we do it too early, daemonize won't work.
        from flup.server.scgi import WSGIServer
        self.scgiserver = WSGIServer(*self.args, **self.kwargs)
        # TODO: report this bug upstream to flup.
        # If we don't set _oldSIGs on Windows, we get:
        #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
        #   line 108, in run
        #     self._restoreSignalHandlers()
        #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
        #   line 156, in _restoreSignalHandlers
        #     for signum,handler in self._oldSIGs:
        #   AttributeError: 'WSGIServer' object has no attribute '_oldSIGs'
        self.scgiserver._installSignalHandlers = lambda: None
        self.scgiserver._oldSIGs = []
        self.ready = True
        self.scgiserver.run()
    
    def stop(self):
        """Stop the HTTP server."""
        self.ready = False
        # Forcibly stop the scgi server main event loop.
        self.scgiserver._keepGoing = False
        # Force all worker threads to die off.
        self.scgiserver._threadPool.maxSpare = 0
开发者ID:AsherBond,项目名称:DimSim,代码行数:35,代码来源:servers.py

示例5: main

def main():
    app = create_app()

    log_fmt = logging.Formatter("[%(asctime)s] %(module)s " "%(levelname)s %(message)s")

    suggestion_log_path = os.path.join(app.instance_path, "database.log")
    suggestion_handler = logging.FileHandler(suggestion_log_path)
    suggestion_handler.setFormatter(log_fmt)
    database.log.addHandler(suggestion_handler)

    import sys

    if len(sys.argv) > 1:
        cmd = sys.argv[1]
    else:
        cmd = "runserver"

    if cmd == "runserver":
        app.run(debug=True)
    elif cmd == "shell":
        from code import interact

        with app.test_request_context():
            interact(local={"app": app})
    elif cmd == "fastcgi":
        from flup.server.fcgi import WSGIServer

        error_log_path = os.path.join(app.instance_path, "error.log")
        error_handler = logging.FileHandler(error_log_path)
        error_handler.setFormatter(log_fmt)
        error_handler.setLevel(logging.ERROR)
        logging.getLogger().addHandler(error_handler)
        sock_path = os.path.join(app.instance_path, "fcgi.sock")
        server = WSGIServer(app, bindAddress=sock_path, umask=0)
        server.run()
    elif cmd == "update_identities":
        import sync

        with app.test_request_context():
            sync.update_identities()
    elif cmd == "new_people":
        with app.test_request_context():
            database.add_people(line.strip() for line in sys.stdin)
            database.db.session.commit()
开发者ID:pistruiatul,项目名称:agenda-politicieni,代码行数:44,代码来源:agenda.py

示例6: FlupFCGIServer

class FlupFCGIServer(object):
    """Adapter for a flup.server.fcgi.WSGIServer."""
    
    def __init__(self, *args, **kwargs):
        if kwargs.get('bindAddress', None) is None:
            import socket
            if not hasattr(socket.socket, 'fromfd'):
                raise ValueError(
                    'Dynamic FCGI server not available on this platform. '
                    'You must use a static or external one by providing a '
                    'legal bindAddress.')
        self.args = args
        self.kwargs = kwargs
        self.ready = False
    
    def start(self):
        """Start the FCGI server."""
        # We have to instantiate the server class here because its __init__
        # starts a threadpool. If we do it too early, daemonize won't work.
        from flup.server.fcgi import WSGIServer
        self.fcgiserver = WSGIServer(*self.args, **self.kwargs)
        # TODO: report this bug upstream to flup.
        # If we don't set _oldSIGs on Windows, we get:
        #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
        #   line 108, in run
        #     self._restoreSignalHandlers()
        #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
        #   line 156, in _restoreSignalHandlers
        #     for signum,handler in self._oldSIGs:
        #   AttributeError: 'WSGIServer' object has no attribute '_oldSIGs'
        self.fcgiserver._installSignalHandlers = lambda: None
        self.fcgiserver._oldSIGs = []
        self.ready = True
        self.fcgiserver.run()
    
    def stop(self):
        """Stop the HTTP server."""
        # Forcibly stop the fcgi server main event loop.
        self.fcgiserver._keepGoing = False
        # Force all worker threads to die off.
        self.fcgiserver._threadPool.maxSpare = self.fcgiserver._threadPool._idleCount
        self.ready = False
开发者ID:0-T-0,项目名称:TACTIC,代码行数:42,代码来源:servers.py

示例7: __init__

 def __init__(self, *args, **kwargs):
     from flup.server.fcgi import WSGIServer
     self.fcgiserver = WSGIServer(*args, **kwargs)
     # TODO: report this bug upstream to flup.
     # If we don't set _oldSIGs on Windows, we get:
     #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
     #   line 108, in run
     #     self._restoreSignalHandlers()
     #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
     #   line 156, in _restoreSignalHandlers
     #     for signum,handler in self._oldSIGs:
     #   AttributeError: 'WSGIServer' object has no attribute '_oldSIGs'
     self.fcgiserver._oldSIGs = []
     self.ready = False
开发者ID:fmcingvale,项目名称:cherrypy_gae,代码行数:14,代码来源:servers.py

示例8: start

 def start(self):
     """Start the SCGI server."""
     # We have to instantiate the server class here because its __init__
     # starts a threadpool. If we do it too early, daemonize won't work.
     from flup.server.scgi import WSGIServer
     self.scgiserver = WSGIServer(*self.args, **self.kwargs)
     # TODO: report this bug upstream to flup.
     # If we don't set _oldSIGs on Windows, we get:
     #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
     #   line 108, in run
     #     self._restoreSignalHandlers()
     #   File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py",
     #   line 156, in _restoreSignalHandlers
     #     for signum,handler in self._oldSIGs:
     #   AttributeError: 'WSGIServer' object has no attribute '_oldSIGs'
     self.scgiserver._installSignalHandlers = lambda: None
     self.scgiserver._oldSIGs = []
     self.ready = True
     self.scgiserver.run()
开发者ID:AsherBond,项目名称:DimSim,代码行数:19,代码来源:servers.py

示例9: WSGIServer

from flup.server.fcgi import WSGIServer
from weeklypedia.labs import wsgi_app


wsgi_server = WSGIServer(wsgi_app)


if __name__ == "__main__":
    wsgi_server.run()
开发者ID:jrbsu,项目名称:weeklypedia,代码行数:9,代码来源:run_labs_fcgi.py

示例10: LinkRecommender

    # testLang = u"en";

    # testItems = {
    #     u"Luis Hernández": 1,
    #     u"Mexikói labdarúgó-válogatott": 1,
    #     u"Labdarúgó": 1,
    #     u"CA Boca Juniors": 1,
    #     u"CF Monterrey": 1
    #     }
    # testLang = u"hu";

    # testItems = {
    #     u"باشگاه فوتبال بوکا جونیورز": 1,
    #     u"فوتبال": 1,
    #     u"زبان اسپانیایی": 1,
    #     u"آرژانتین": 1};
    # testLang = u"fa";
   
    # logging.basicConfig(level=logging.DEBUG)

    # recommender = LinkRecommender(lang=testLang, nrecs=2500, verbose=True);
    # recommender.connect();
    # recs = recommender.get_recs(item_map=testItems, \
    #                                 param_map=dict({u'nrecs': 2500,u'lang': testLang}));
    # recommender.close();
    # print "Received %d recommendations." % (len(recs),);

# Also, comment out these if you run from command line
wsgi = WSGIServer(app);
wsgi.run();
开发者ID:stuem007,项目名称:suggestbot,代码行数:30,代码来源:link-recommender.py

示例11: _mainloopPeriodic

 def _mainloopPeriodic(self):
     WSGIServer._mainloopPeriodic(self)
     if getmtime(__file__) != START_TIME:
         self._keepGoing = False
开发者ID:SimonSapin,项目名称:snippets,代码行数:4,代码来源:restarting_flup.py

示例12: handle

 def handle(self, app, sock):
     _production_logging(app)
     from flup.server.fcgi import WSGIServer
     server = WSGIServer(app, bindAddress=sock, umask=0, maxThreads=5)
     server.run()
开发者ID:pombredanne,项目名称:cites-meetings,代码行数:5,代码来源:manage.py

示例13: open

#!/usr/bin/python
"""
FastCGI server using flup. Reloads on SIGHUP.
"""
import site, os
site.addsitedir(os.path.dirname(__file__))
import restrack.server
from flup.server.fcgi import WSGIServer
import os, sys, logging, site

lh = logging.StreamHandler(sys.stderr)
lh.setFormatter(logging.Formatter(restrack.server.FORMAT))
logging.root.addHandler(lh)
logging.root.setLevel(logging.DEBUG)

f = open('/tmp/restracker.pid', 'w')
f.write(str(os.getpid()))
f.close()

try:
	ws = WSGIServer(restrack.server.restracker_app, bindAddress='/tmp/restracker.sock')
	rerun = ws.run()
finally:
	os.unlink('/tmp/restracker.pid')

if rerun:
	os.spawnv(__file__, sys.argv)

开发者ID:astronouth7303,项目名称:restracker,代码行数:27,代码来源:fastcgi-server.py

示例14: run_fcgi

def run_fcgi(app, args):
    from flup.server.fcgi import WSGIServer
    sock_path = args.fastcgi_socket
    wsgi_server = WSGIServer(app, bindAddress=sock_path, umask=0)
    wsgi_server.run()
开发者ID:mgax,项目名称:civic-site,代码行数:5,代码来源:civic_site.py

示例15: handle

 def handle(self, app):
     _production_logging(app)
     from flup.server.fcgi import WSGIServer
     sock_path = os.path.join(app.instance_path, 'fcgi.sock')
     server = WSGIServer(app, bindAddress=sock_path, umask=0)
     server.run()
开发者ID:dincamihai,项目名称:cites-meetings,代码行数:6,代码来源:manage.py


注:本文中的flup.server.fcgi.WSGIServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。