How to use the gitdb.util.mman function in gitdb

To help you get started, we’ve selected a few gitdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github h3llrais3r / Auto-Subliminal / lib / gitdb / pack.py View on Github external
def close(self):
        mman.force_map_handle_removal_win(self._packpath)
        self._cursor = None
github gitpython-developers / GitPython / git / repo / base.py View on Github external
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()
github apache / allura / ForgeGit / forgegit / model / git_repo.py View on Github external
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):
github gitpython-developers / GitPython / git / repo / base.py View on Github external
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()
github h3llrais3r / Auto-Subliminal / lib / git / repo / base.py View on Github external
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()
github gitpython-developers / gitdb / gitdb / pack.py View on Github external
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)
github h3llrais3r / Auto-Subliminal / lib / gitdb / pack.py View on Github external
def close(self):
        mman.force_map_handle_removal_win(self._indexpath)
        self._cursor = None
github gitpython-developers / gitdb / gitdb / pack.py View on Github external
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
github h3llrais3r / Auto-Subliminal / lib / gitdb / pack.py View on Github external
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
github gitpython-developers / gitdb / gitdb / pack.py View on Github external
def close(self):
        mman.force_map_handle_removal_win(self._indexpath)
        self._cursor = None