remove some useless code. pyflakes my friend.

This commit is contained in:
benoitc 2010-12-22 19:52:34 +01:00
parent c90ecd1eba
commit 16fd5d3c20
8 changed files with 17 additions and 14 deletions

View File

@ -74,7 +74,7 @@ class Application(object):
}
try:
execfile(opts.config, cfg, cfg)
except Exception, e:
except Exception:
print "Failed to read config file: %s" % opts.config
traceback.print_exc()
sys.exit(1)

View File

@ -3,7 +3,6 @@
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import logging
import os
import sys
import traceback
@ -60,7 +59,7 @@ class DjangoApplication(Application):
for part in parts[1:]:
settings_mod = getattr(settings_mod, part)
setup_environ(settings_mod)
except ImportError, e:
except ImportError:
return self.no_settings(self.settings_modname, import_error=True)
def no_settings(self, path, import_error=False):
@ -102,7 +101,7 @@ class DjangoApplicationCommand(Application):
}
try:
execfile(self.config_file, cfg, cfg)
except Exception, e:
except Exception:
print "Failed to read config file: %s" % self.config_file
traceback.print_exc()
sys.exit(1)

View File

@ -14,7 +14,7 @@ import sys
import time
import traceback
from gunicorn.errors import ConfigError, HaltServer
from gunicorn.errors import HaltServer
from gunicorn.pidfile import Pidfile
from gunicorn.sock import create_socket
from gunicorn import util

View File

@ -9,7 +9,6 @@ import inspect
import optparse
import os
import pwd
import sys
import textwrap
import types

View File

@ -7,7 +7,6 @@ from __future__ import with_statement
import errno
import socket
import traceback
import gunicorn.http as http
import gunicorn.http.wsgi as wsgi
@ -54,7 +53,6 @@ class AsyncWorker(base.Worker):
def handle_request(self, req, sock, addr):
try:
debug = self.cfg.debug or False
self.cfg.pre_request(self, req)
resp, environ = wsgi.create(req, sock, addr, self.address, self.cfg)
self.nr += 1

View File

@ -9,7 +9,6 @@ import os
import random
import signal
import sys
import tempfile
import traceback
@ -116,9 +115,7 @@ class Worker(object):
self.alive = False
sys.exit(0)
def handle_error(self, client, exc):
if isinstance(exc, (InvalidRequestLine, InvalidRequestMethod,
InvalidHTTPVersion, InvalidHeader, InvalidHeaderName,)):
@ -144,8 +141,10 @@ class Worker(object):
util.write_error(client, mesg, status_int=status_int,
reason=reason)
except:
self.log.warning("Unexpected error" % traceback.format_exc())
pass
if self.debug:
self.log.warning("Unexpected error %s" % traceback.format_exc())
else:
self.log.warning("Unexpected error %s" % str(exc))
def handle_winch(self, sig, fname):
# Ignore SIGWINCH in worker. Fixes a crash on OpenBSD.

View File

@ -123,6 +123,7 @@ class GeventBaseWorker(Worker):
@classmethod
def setup(cls):
from gevent import monkey
monkey.noisy = False
monkey.patch_all()
@ -152,6 +153,14 @@ class GeventBaseWorker(Worker):
server.stop(timeout=self.timeout)
except:
pass
def init_process(self):
#gevent doesn't reinitialize dns for us after forking
#here's the workaround
gevent.core.dns_shutdown(fail_requests=1)
gevent.core.dns_init()
super(GeventBaseWorker, self).init_process()
class WSGIHandler(wsgi.WSGIHandler):

View File

@ -83,7 +83,6 @@ class SyncWorker(base.Worker):
def handle_request(self, req, client, addr):
try:
debug = self.cfg.debug or False
self.cfg.pre_request(self, req)
resp, environ = wsgi.create(req, client, addr,
self.address, self.cfg)