未验证 提交 98ea5f17 编写于 作者: B Bin Long 提交者: GitHub

Merge pull request #313 from ShenYuhan/gix_windows_gunicorn

fix windows gunicorn dependment.
...@@ -26,30 +26,42 @@ import paddlehub as hub ...@@ -26,30 +26,42 @@ import paddlehub as hub
from paddlehub.commands.base_command import BaseCommand, ENTRY from paddlehub.commands.base_command import BaseCommand, ENTRY
from paddlehub.serving import app_single as app from paddlehub.serving import app_single as app
import multiprocessing import multiprocessing
import gunicorn.app.base
if platform.system() == "Windows":
def number_of_workers(): class StandaloneApplication(object):
return (multiprocessing.cpu_count() * 2) + 1 def __init__(self):
pass
def load_config(self):
pass
def load(self):
pass
else:
import gunicorn.app.base
class StandaloneApplication(gunicorn.app.base.BaseApplication):
def __init__(self, app, options=None):
self.options = options or {}
self.application = app
super(StandaloneApplication, self).__init__()
class StandaloneApplication(gunicorn.app.base.BaseApplication): def load_config(self):
def __init__(self, app, options=None): config = {
self.options = options or {} key: value
self.application = app for key, value in self.options.items()
super(StandaloneApplication, self).__init__() if key in self.cfg.settings and value is not None
}
for key, value in config.items():
self.cfg.set(key.lower(), value)
def load_config(self): def load(self):
config = { return self.application
key: value
for key, value in self.options.items()
if key in self.cfg.settings and value is not None
}
for key, value in config.items():
self.cfg.set(key.lower(), value)
def load(self):
return self.application def number_of_workers():
return (multiprocessing.cpu_count() * 2) + 1
class ServingCommand(BaseCommand): class ServingCommand(BaseCommand):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册