diff --git a/gunicorn/http/request.py b/gunicorn/http/request.py index 7d720758..4be36a82 100644 --- a/gunicorn/http/request.py +++ b/gunicorn/http/request.py @@ -3,11 +3,9 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -import ctypes import logging import os import re -import socket import StringIO import sys from urllib import unquote diff --git a/gunicorn/http/tee.py b/gunicorn/http/tee.py index fdf6cb90..fd476cdb 100644 --- a/gunicorn/http/tee.py +++ b/gunicorn/http/tee.py @@ -15,7 +15,7 @@ import os import StringIO import tempfile -from gunicorn.util import MAX_BODY, CHUNK_SIZE, read_partial, fsize, fwrite +from gunicorn.util import MAX_BODY, CHUNK_SIZE, read_partial class TeeInput(object): @@ -154,7 +154,10 @@ class TeeInput(object): self._is_socket = False def _tmp_size(self): - return fsize(self.tmp) + if isinstance(self.tmp, StringIO.StringIO): + return self.tmp.len + else: + return int(os.fstat(self.tmp.fileno())[6]) def _ensure_length(self, buf, length): if not buf or not self._len: diff --git a/gunicorn/management/commands/run_gunicorn.py b/gunicorn/management/commands/run_gunicorn.py index 804e9c73..b68f348e 100644 --- a/gunicorn/management/commands/run_gunicorn.py +++ b/gunicorn/management/commands/run_gunicorn.py @@ -17,8 +17,7 @@ from django.core.handlers.wsgi import WSGIHandler from gunicorn.arbiter import Arbiter from gunicorn.config import Config -from gunicorn.main import daemonize, UMASK, configure_logging -from gunicorn.util import parse_address, to_bytestring +from gunicorn.main import daemonize, configure_logging class Command(BaseCommand): option_list = BaseCommand.option_list + ( diff --git a/gunicorn/util.py b/gunicorn/util.py index 85b57d38..7d8593bb 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -5,13 +5,10 @@ import array import ctypes -import errno import fcntl import os import resource -import select import socket -import StringIO import textwrap import time @@ -148,23 +145,6 @@ def write_error(sock, msg): %s """) % (len(html), html) write_nonblock(sock, http) - -def fwrite(f, data): - pos = f.tell() - f.seek(fsize(f)) - f.write(data) - f.flush() - if hasattr(f, 'fileno'): - os.fsync(f.fileno()) - f.seek(0, os.SEEK_END) - f.seek(pos) - -def fsize(f): - if isinstance(f, StringIO.StringIO): - return f.len - else: - return int(os.fstat(f.fileno())[6]) - def normalize_name(name): return "-".join([w.lower().capitalize() for w in name.split("-")])