Skip to content

Commit 8d64e74

Browse files
committed
Added very special purpose method to free memory maps. The whole reason for this is to make the windows test work after all \!
1 parent aafc980 commit 8d64e74

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

smmap/mman.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,32 @@ def page_size(self):
426426
return PAGESIZE
427427

428428
#} END interface
429+
430+
#{ Special Purpose Interface
431+
432+
def force_map_handle_removal_win(self, base_path):
433+
"""ONLY AVAILABLE ON WINDOWS
434+
On windows removing files is not allowed if anybody still has it opened.
435+
If this process is ourselves, and if the whole process uses this memory
436+
manager (as far as the parent framework is concerned) we can enforce
437+
closing all memory maps whose path matches the given base path to
438+
allow the respective operation after all.
439+
The respective system must NOT access the closed memory regions anymore !
440+
This really may only be used if you know that the items which keep
441+
the cursors alive will not be using it anymore. They need to be recreated !
442+
:return: Amount of closed handles
443+
:note: does nothing on non-windows platforms"""
444+
if sys.platform != 'win32':
445+
return
446+
#END early bailout
447+
448+
num_closed = 0
449+
for path, rlist in self._fdict.iteritems():
450+
if path.startswith(base_path):
451+
for region in rlist:
452+
region._mf.close()
453+
num_closed += 1
454+
#END path matches
455+
#END for each path
456+
return num_closed
457+
#} END special purpose interface

0 commit comments

Comments
 (0)