Skip to content

Commit 05c95bd

Browse files
committed
Adds a comment in README.rst noting that in the case of MODE_FD it is ultimately the caller's responsibility to be sure the file gets closed.
1 parent b53e6bd commit 05c95bd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ provide `free GeoLite2 databases
4040
<http://dev.maxmind.com/geoip/geoip2/geolite2>`_. These files must be
4141
decompressed with ``gunzip``.
4242

43-
After you have obtained a database and importing the module, call
44-
``open_database`` with a path to the database as the first argument.
45-
Optionally, you may pass a mode as the second argument. The modes are
46-
exported from ``maxminddb``. Valid modes are:
43+
After you have obtained a database and imported the module, call
44+
``open_database`` with a path, or file descriptor (in the case of MODE_FD),
45+
to the database as the first argument. Optionally, you may pass a mode as the
46+
second argument. The modes are exported from ``maxminddb``. Valid modes are:
4747

4848
* MODE_MMAP_EXT - use the C extension with memory map.
4949
* MODE_MMAP - read from memory map. Pure Python.
@@ -52,6 +52,10 @@ exported from ``maxminddb``. Valid modes are:
5252
* MODE_FD - load database into memory from a file descriptor. Pure Python.
5353
* MODE_AUTO - try MODE_MMAP_EXT, MODE_MMAP, MODE_FILE in that order. Default.
5454

55+
**NOTE**: When using ``MODE_FD``, it is the *caller's* responsibility to be
56+
sure that the file descriptor gets closed properly, even though this module
57+
*may* close it after the ``Reader`` object is created.
58+
5559
The ``open_database`` function returns a ``Reader`` object. To look up an IP
5660
address, use the ``get`` method on this object. The method will return the
5761
corresponding values for the IP address from the database (e.g., a dictionary

0 commit comments

Comments
 (0)