Catch ctypes import errors.

This commit is contained in:
Dan Sully 2011-03-22 09:30:54 -07:00 committed by benoitc
parent b7adfe2628
commit 4f96ccedc1
2 changed files with 15 additions and 6 deletions

View File

@ -3,18 +3,24 @@
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
import ctypes
import ctypes.util
import errno import errno
import os import os
import sys import sys
# Python on Solaris compiled with Sun Studio doesn't have ctypes.
try:
import ctypes
import ctypes.util
if sys.version_info >= (2, 6): if sys.version_info >= (2, 6):
_libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True) _libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True)
_sendfile = _libc.sendfile _sendfile = _libc.sendfile
else: else:
_sendfile = None _sendfile = None
except ImportError:
_sendfile = None
if _sendfile: if _sendfile:
if sys.platform == 'darwin': if sys.platform == 'darwin':
# MacOS X - int sendfile(int fd, int s, off_t offset, off_t *len, # MacOS X - int sendfile(int fd, int s, off_t offset, off_t *len,

View File

@ -10,6 +10,9 @@ except MemoryError:
# selinux execmem denial # selinux execmem denial
# https://bugzilla.redhat.com/show_bug.cgi?id=488396 # https://bugzilla.redhat.com/show_bug.cgi?id=488396
ctypes = None ctypes = None
except ImportError:
# Python on Solaris compiled with Sun Studio doesn't have ctypes
ctypes = None
import fcntl import fcntl
import os import os