use uWSGIs locking
This commit is contained in:
parent
9a8e0b524e
commit
55b6b283b8
1
isso.ini
1
isso.ini
@ -3,7 +3,6 @@ http = :8080
|
|||||||
master = true
|
master = true
|
||||||
processes = 4
|
processes = 4
|
||||||
spooler = %v/mail
|
spooler = %v/mail
|
||||||
queue = 1
|
|
||||||
module = isso
|
module = isso
|
||||||
virtualenv = .
|
virtualenv = .
|
||||||
env = ISSO_SETTINGS=%v/sample.cfg
|
env = ISSO_SETTINGS=%v/sample.cfg
|
||||||
|
@ -197,13 +197,10 @@ class uWSGIMixin(Mixin):
|
|||||||
class Lock():
|
class Lock():
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
while uwsgi.queue_get(0) == "LOCK":
|
uwsgi.lock()
|
||||||
time.sleep(0.01)
|
|
||||||
|
|
||||||
uwsgi.queue_set(0, "LOCK")
|
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
uwsgi.queue_pop()
|
uwsgi.unlock()
|
||||||
|
|
||||||
def spooler(args):
|
def spooler(args):
|
||||||
try:
|
try:
|
||||||
|
@ -70,23 +70,20 @@ def new(app, environ, request, uri):
|
|||||||
data['mode'] = (app.conf.getboolean('moderation', 'enabled') and 2) or 1
|
data['mode'] = (app.conf.getboolean('moderation', 'enabled') and 2) or 1
|
||||||
data['remote_addr'] = utils.anonymize(str(request.remote_addr))
|
data['remote_addr'] = utils.anonymize(str(request.remote_addr))
|
||||||
|
|
||||||
# extract site's <h1> title
|
|
||||||
if uri not in app.db.threads:
|
|
||||||
for host in app.conf.getiter('general', 'host'):
|
|
||||||
resp = http.curl('HEAD', host, uri)
|
|
||||||
if resp and resp.status == 200:
|
|
||||||
title = parse.title(resp.read())
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
return Response('URI does not exist', 404)
|
|
||||||
else:
|
|
||||||
title = app.db.threads[uri].title
|
|
||||||
|
|
||||||
with app.lock:
|
with app.lock:
|
||||||
if uri not in app.db.threads:
|
if uri not in app.db.threads:
|
||||||
app.db.threads.new(uri, title)
|
for host in app.conf.getiter('general', 'host'):
|
||||||
|
resp = http.curl('HEAD', host, uri)
|
||||||
|
if resp and resp.status == 200:
|
||||||
|
title = parse.title(resp.read())
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return Response('URI does not exist', 404)
|
||||||
|
|
||||||
logger.info('new thread: %s -> %s', uri, title)
|
app.db.threads.new(uri, title)
|
||||||
|
logger.info('new thread: %s -> %s', uri, title)
|
||||||
|
else:
|
||||||
|
title = app.db.threads[uri].title
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with app.lock:
|
with app.lock:
|
||||||
|
Loading…
Reference in New Issue
Block a user