make_app uses threading.Lock now by default
Uses keyword arguments to use multiprocessing or uwsgi mixin. This fixes an issue on exotic *BSDs such as NetBSD where Python comes not with inter-process semaphores (issue 3307): mod_wsgi (pid=14365): Target WSGI script '/var/www/vhosts/my.hostname.org/htdocs/isso.wsgi' cannot be loaded as Python module. mod_wsgi (pid=14365): Exception occurred processing WSGI script '/var/www/vhosts/my.hostname.org/htdocs/isso.wsgi'. Traceback (most recent call last): File "/var/www/vhosts/my.hostname.org/htdocs/isso.wsgi", line 8, in <module> application = make_app(Config.load("/var/www/vhosts/my.hostname.org/htdocs/isso.cfg")) File "/usr/pkg/lib/python2.7/site-packages/isso/__init__.py", line 155, in make_app isso = App(conf) File "/usr/pkg/lib/python2.7/site-packages/isso/__init__.py", line 91, in __init__ super(Isso, self).__init__(conf) File "/usr/pkg/lib/python2.7/site-packages/isso/core.py", line 223, in __init__ self.lock = multiprocessing.Lock() File "/usr/pkg/lib/python2.7/multiprocessing/__init__.py", line 175, in Lock from multiprocessing.synchronize import Lock File "/usr/pkg/lib/python2.7/multiprocessing/synchronize.py", line 59, in <module> " function, see issue 3770.") ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.
This commit is contained in:
parent
a7375e8016
commit
fcd0a01de3
@ -30,16 +30,15 @@ from __future__ import print_function
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
dist = pkg_resources.get_distribution("isso")
|
dist = pkg_resources.get_distribution("isso")
|
||||||
|
|
||||||
try:
|
# check if exectuable is `isso` and gevent is available
|
||||||
import uwsgi
|
import sys
|
||||||
except ImportError:
|
|
||||||
uwsgi = None
|
if sys.argv[0].startswith("isso"):
|
||||||
try:
|
try:
|
||||||
import gevent.monkey; gevent.monkey.patch_all()
|
import gevent.monkey; gevent.monkey.patch_all()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
gevent = None
|
pass
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import errno
|
import errno
|
||||||
import logging
|
import logging
|
||||||
@ -140,17 +139,19 @@ class Isso(object):
|
|||||||
return self.wsgi_app(environ, start_response)
|
return self.wsgi_app(environ, start_response)
|
||||||
|
|
||||||
|
|
||||||
def make_app(conf=None):
|
def make_app(conf=None, threading=True, multiprocessing=False, uwsgi=False):
|
||||||
|
|
||||||
|
if threading:
|
||||||
|
class App(Isso, ThreadedMixin):
|
||||||
|
pass
|
||||||
|
|
||||||
|
if multiprocessing:
|
||||||
|
class App(Isso, ProcessMixin):
|
||||||
|
pass
|
||||||
|
|
||||||
if uwsgi:
|
if uwsgi:
|
||||||
class App(Isso, uWSGIMixin):
|
class App(Isso, uWSGIMixin):
|
||||||
pass
|
pass
|
||||||
elif gevent or sys.argv[0].endswith("isso"):
|
|
||||||
class App(Isso, ThreadedMixin):
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
class App(Isso, ProcessMixin):
|
|
||||||
pass
|
|
||||||
|
|
||||||
isso = App(conf)
|
isso = App(conf)
|
||||||
|
|
||||||
|
@ -5,4 +5,5 @@ import os
|
|||||||
from isso import make_app
|
from isso import make_app
|
||||||
from isso.core import Config
|
from isso.core import Config
|
||||||
|
|
||||||
application = make_app(Config.load(os.environ.get('ISSO_SETTINGS')))
|
application = make_app(Config.load(os.environ.get('ISSO_SETTINGS')),
|
||||||
|
multiprocessing=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user