Commit a7c76a6f by Kiril Zyapkov Committed by William Tisäter

Enable use in Google AppEngine

parent 2b314f4e
......@@ -26,11 +26,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
import os
import math
import socket
import mmap
import codecs
from threading import Lock
try:
import mmap
except ImportError:
mmap = None
try:
from StringIO import StringIO
except ImportError:
from io import StringIO, BytesIO
......@@ -93,7 +97,12 @@ class GeoIP(GeoIPBase):
self._filename = filename
self._flags = flags
if self._flags & const.MMAP_CACHE:
if self._flags & const.MMAP_CACHE and mmap is None:
import warnings
warnings.warn("MMAP_CACHE cannot be used without a mmap module")
self._flags &= ~const.MMAP_CACHE
elif self._flags & const.MMAP_CACHE:
f = open(filename, 'rb')
access = mmap.ACCESS_READ
self._filehandle = mmap.mmap(f.fileno(), 0, access=access)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment