New submission from Manuel <manuel.schoell...@gmx.de>:

mmap.mmap(fileno, length, flags, prot, access, offset) always clones the file 
descriptor that should be used [1].

The cloning of the file descriptor seems to be done to ensure that the file 
cannot be closed behind mmap's back, but if you are mmap()'ing a lot of memory 
regions of a file this can cause a 'Too many open files' error.

I would suggest to add an option to mmap.mmap() that tells it not to clone the 
file descriptor. This can cause an issue if the file is closed before accessing 
the mmapped region, so this fact should also be pointed out in the 
documentation.

[1] https://github.com/python/cpython/blob/master/Modules/mmapmodule.c#L1159

----------
components: Library (Lib)
messages: 322953
nosy: manuels
priority: normal
severity: normal
status: open
title: mmap.mmap() should not necessarily clone the file descriptor
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34321>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to