appliedsec/pygeoip — pull request #13 by wmalinowski (2012-07-04 21:17:36+00:00)
Title: Thread safety

The current version is not thread safe and is therefore not useful for i.e. multithreaded web applications. The attached tests show that the functions either return wrong results or raise different exceptions.

The pull request fixes the issue by using a simple lock to wrap file.seek()/file.read() pairs.

This would probably be best refactored along with the mmap/StringIO functionality into a generic StringIO (BytesIO perhaps) descendant with a seek_and_read() method with better error handling.