else:
template = 'tmp' # XXX might choose a better one
+_pidcache = {}
def gettempprefix():
"""Function to calculate a prefix of the filename to use.
notion, so that concurrent processes don't generate the same prefix.
"""
- global template
if template is None:
- return '@' + `os.getpid()` + '.'
+ p = os.getpid()
+ t = _pidcache.get(p, 0)
+ if t:
+ return t
+ if len(_pidcache) > 100: # stop unbounded growth
+ _pidcache.clear()
+ t = _pidcache[p] = '@' + `p` + '.'
+ return t
else:
return template
test_mmap
+<type 'mmap'>
Position of foo: 1.0 pages
Length of file: 2.0 pages
Contents of byte 0: '\000'
f.close()
# Simple sanity checks
+
+ print type(m) # SF bug 128713: segfaulted on Linux
print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages'
assert string.find(m, 'foo') == PAGESIZE
int fileno;
HANDLE fh = 0;
- /* Patch the object type */
- mmap_object_type.ob_type = &PyType_Type;
-
if (!PyArg_ParseTuple(args,
"iO|z",
&fileno,
initmmap(void)
{
PyObject *dict, *module;
+
+ /* Patch the object type */
+ mmap_object_type.ob_type = &PyType_Type;
+
module = Py_InitModule ("mmap", mmap_functions);
dict = PyModule_GetDict (module);
mmap_module_error = PyExc_EnvironmentError;