Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def close(self):
mman.force_map_handle_removal_win(self._packpath)
self._cursor = None
def close(self):
if self.git:
self.git.clear_cache()
# Tempfiles objects on Windows are holding references to
# open files until they are collected by the garbage
# collector, thus preventing deletion.
# TODO: Find these references and ensure they are closed
# and deleted synchronously rather than forcing a gc
# collection.
if is_win:
gc.collect()
gitdb.util.mman.collect()
if is_win:
gc.collect()
import gitdb
from tg import tmpl_context as c
from pymongo.errors import DuplicateKeyError
from paste.deploy.converters import asbool
from ming.base import Object
from ming.orm import Mapper, session
from ming.utils import LazyProperty
from allura.lib import helpers as h
from allura.model.repository import topological_sort, prefix_paths_union
from allura import model as M
log = logging.getLogger(__name__)
gitdb.util.mman = gitdb.util.mman.__class__(
max_open_handles=128)
class GitLibCmdWrapper(object):
def __init__(self, client):
self.client = client
def __getattr__(self, name):
return getattr(self.client, name)
def log(self, *args, **kwargs):
return self.client.log(*args, **kwargs)
class Repository(M.Repository):
def close(self):
if self.git:
self.git.clear_cache()
# Tempfiles objects on Windows are holding references to
# open files until they are collected by the garbage
# collector, thus preventing deletion.
# TODO: Find these references and ensure they are closed
# and deleted synchronously rather than forcing a gc
# collection.
if is_win:
gc.collect()
gitdb.util.mman.collect()
if is_win:
gc.collect()
def close(self):
if self.git:
self.git.clear_cache()
# Tempfiles objects on Windows are holding references to
# open files until they are collected by the garbage
# collector, thus preventing deletion.
# TODO: Find these references and ensure they are closed
# and deleted synchronously rather than forcing a gc
# collection.
if is_win:
gc.collect()
gitdb.util.mman.collect()
if is_win:
gc.collect()
def _set_cache_(self, attr):
# we fill the whole cache, whichever attribute gets queried first
self._cursor = mman.make_cursor(self._packpath).use_region()
# read the header information
type_id, self._version, self._size = unpack_from(">LLL", self._cursor.map(), 0)
# TODO: figure out whether we should better keep the lock, or maybe
# add a .keep file instead ?
if type_id != self.pack_signature:
raise ParseError("Invalid pack signature: %i" % type_id)
def close(self):
mman.force_map_handle_removal_win(self._indexpath)
self._cursor = None
def _set_cache_(self, attr):
if attr == "_packfile_checksum":
self._packfile_checksum = self._cursor.map()[-40:-20]
elif attr == "_packfile_checksum":
self._packfile_checksum = self._cursor.map()[-20:]
elif attr == "_cursor":
# Note: We don't lock the file when reading as we cannot be sure
# that we can actually write to the location - it could be a read-only
# alternate for instance
self._cursor = mman.make_cursor(self._indexpath).use_region()
# We will assume that the index will always fully fit into memory !
if mman.window_size() > 0 and self._cursor.file_size() > mman.window_size():
raise AssertionError("The index file at %s is too large to fit into a mapped window (%i > %i). This is a limitation of the implementation" % (
self._indexpath, self._cursor.file_size(), mman.window_size()))
# END assert window size
else:
# now its time to initialize everything - if we are here, someone wants
# to access the fanout table or related properties
# CHECK VERSION
mmap = self._cursor.map()
self._version = (mmap[:4] == self.index_v2_signature and 2) or 1
if self._version == 2:
version_id = unpack_from(">L", mmap, 4)[0]
assert version_id == self._version, "Unsupported index version: %i" % version_id
# END assert version
# SETUP FUNCTIONS
def _set_cache_(self, attr):
if attr == "_packfile_checksum":
self._packfile_checksum = self._cursor.map()[-40:-20]
elif attr == "_packfile_checksum":
self._packfile_checksum = self._cursor.map()[-20:]
elif attr == "_cursor":
# Note: We don't lock the file when reading as we cannot be sure
# that we can actually write to the location - it could be a read-only
# alternate for instance
self._cursor = mman.make_cursor(self._indexpath).use_region()
# We will assume that the index will always fully fit into memory !
if mman.window_size() > 0 and self._cursor.file_size() > mman.window_size():
raise AssertionError("The index file at %s is too large to fit into a mapped window (%i > %i). This is a limitation of the implementation" % (
self._indexpath, self._cursor.file_size(), mman.window_size()))
# END assert window size
else:
# now its time to initialize everything - if we are here, someone wants
# to access the fanout table or related properties
# CHECK VERSION
mmap = self._cursor.map()
self._version = (mmap[:4] == self.index_v2_signature and 2) or 1
if self._version == 2:
version_id = unpack_from(">L", mmap, 4)[0]
assert version_id == self._version, "Unsupported index version: %i" % version_id
# END assert version
def close(self):
mman.force_map_handle_removal_win(self._indexpath)
self._cursor = None