當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。