当前位置: 首页>>代码示例>>Python>>正文


Python mmap.PAGESIZE属性代码示例

本文整理汇总了Python中mmap.PAGESIZE属性的典型用法代码示例。如果您正苦于以下问题:Python mmap.PAGESIZE属性的具体用法?Python mmap.PAGESIZE怎么用?Python mmap.PAGESIZE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在mmap的用法示例。


在下文中一共展示了mmap.PAGESIZE属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def __init__(self, *args, **kwds):
        ## Create shared memory for rendered image
        #pg.dbg(namespace={'r': self})
        if sys.platform.startswith('win'):
            self.shmtag = "pyqtgraph_shmem_" + ''.join([chr((random.getrandbits(20)%25) + 97) for i in range(20)])
            self.shm = mmap.mmap(-1, mmap.PAGESIZE, self.shmtag) # use anonymous mmap on windows
        else:
            self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_')
            self.shmFile.write(b'\x00' * (mmap.PAGESIZE+1))
            fd = self.shmFile.fileno()
            self.shm = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE)
        atexit.register(self.close)
        
        GraphicsView.__init__(self, *args, **kwds)
        self.scene().changed.connect(self.update)
        self.img = None
        self.renderTimer = QtCore.QTimer()
        self.renderTimer.timeout.connect(self.renderView)
        self.renderTimer.start(16) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:21,代码来源:RemoteGraphicsView.py

示例2: _malloc

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def _malloc(self, size):
        # returns a large enough block -- it might be much larger
        i = bisect.bisect_left(self._lengths, size)
        if i == len(self._lengths):
            length = self._roundup(max(self._size, size), mmap.PAGESIZE)
            self._size *= 2
            info('allocating a new mmap of length %d', length)
            arena = Arena(length)
            self._arenas.append(arena)
            return (arena, 0, length)
        else:
            length = self._lengths[i]
            seq = self._len_to_seq[length]
            block = seq.pop()
            if not seq:
                del self._len_to_seq[length], self._lengths[i]

        (arena, start, stop) = block
        del self._start_to_block[(arena, start)]
        del self._stop_to_block[(arena, stop)]
        return block 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:heap.py

示例3: _malloc

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def _malloc(self, size):
        # returns a large enough block -- it might be much larger
        i = bisect.bisect_left(self._lengths, size)
        if i == len(self._lengths):
            length = self._roundup(max(self._size, size), mmap.PAGESIZE)
            self._size *= 2
            util.info('allocating a new mmap of length %d', length)
            arena = Arena(length)
            self._arenas.append(arena)
            return (arena, 0, length)
        else:
            length = self._lengths[i]
            seq = self._len_to_seq[length]
            block = seq.pop()
            if not seq:
                del self._len_to_seq[length], self._lengths[i]

        (arena, start, stop) = block
        del self._start_to_block[(arena, start)]
        del self._stop_to_block[(arena, stop)]
        return block 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:heap.py

示例4: __init__

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def __init__(self, address, port, timeout, buffer_size=PAGESIZE,
                 lock_class=Semaphore):
        self.address = address
        self.port = port
        self.timeout = timeout

        self.buffer = b''
        self.buffer_size = buffer_size

        self.socket = None
        self.lock = lock_class() 
开发者ID:wtolson,项目名称:gnsq,代码行数:13,代码来源:stream.py

示例5: __init__

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def __init__(self, size=mmap.PAGESIZE):
        self._lastpid = os.getpid()
        self._lock = threading.Lock()
        self._size = size
        self._lengths = []
        self._len_to_seq = {}
        self._start_to_block = {}
        self._stop_to_block = {}
        self._allocated_blocks = set()
        self._arenas = []
        # list of pending blocks to free - see free() comment below
        self._pending_free_blocks = [] 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:heap.py

示例6: test_mmap_find_large

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def test_mmap_find_large():
        P10 = PAGESIZE * 10
        P11 = PAGESIZE * 11
        f = open(TESTFN, 'w+')
        try:
            f.write((P10 - 1) * '\0')
            f.write('foofoo')
            f.write('\0' * PAGESIZE)
            f.write('foo')
            f.flush()
            m = mmap.mmap(f.fileno(), P11 + 8)
            f.close()

            AreEqual(m.find('foo'), P10 - 1)
            AreEqual(m.find('foo', P10 - 1), P10 - 1)
            AreEqual(m.find('foo', P10), P10 + 2)
            AreEqual(m.find('foo', P10 + 173), P11 + 5)
            AreEqual(m.find('foo', P10 + 173, P11 + 7), -1)

        finally:
            m.close()
            try:
                f.close()
            except OSError:
                pass

        mmap_tearDown() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:29,代码来源:python26.py

示例7: test_mmap_rfind_large

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def test_mmap_rfind_large():
        P10 = PAGESIZE * 10
        P11 = PAGESIZE * 11
        f = open(TESTFN, 'w+')
        try:
            f.write((P10 - 1) * '\0')
            f.write('foofoo')
            f.write('\0' * PAGESIZE)
            f.write('foo')
            f.flush()
            m = mmap.mmap(f.fileno(), P11 + 8)
            f.close()

            AreEqual(m.rfind('foo'), P11 + 5)
            AreEqual(m.rfind('foo', 651, P11 - 117), P10 + 2)
            AreEqual(m.rfind('foo', 475, P10 + 5), P10 + 2)
            AreEqual(m.rfind('foo', 475, P10 + 4), P10 - 1)
            AreEqual(m.rfind('foo', P10 + 4, P11 + 7), -1)
            AreEqual(m.rfind('foo', P10 + 4), P11 + 5)

        finally:
            m.close()
            try:
                f.close()
            except OSError:
                pass

        mmap_tearDown()


#--MAIN------------------------------------------------------------------------ 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:python26.py

示例8: _decompress_dwarf_section

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def _decompress_dwarf_section(section):
        """ Returns the uncompressed contents of the provided DWARF section.
        """
        # TODO: support other compression formats from readelf.c
        assert section.size > 12, 'Unsupported compression format.'

        section.stream.seek(0)
        # According to readelf.c the content should contain "ZLIB"
        # followed by the uncompressed section size - 8 bytes in
        # big-endian order
        compression_type = section.stream.read(4)
        assert compression_type == b'ZLIB', \
            'Invalid compression type: %r' % (compression_type)

        uncompressed_size = struct.unpack('>Q', section.stream.read(8))[0]

        decompressor = zlib.decompressobj()
        uncompressed_stream = BytesIO()
        while True:
            chunk = section.stream.read(PAGESIZE)
            if not chunk:
                break
            uncompressed_stream.write(decompressor.decompress(chunk))
        uncompressed_stream.write(decompressor.flush())

        uncompressed_stream.seek(0, io.SEEK_END)
        size = uncompressed_stream.tell()
        assert uncompressed_size == size, \
                'Wrong uncompressed size: expected %r, but got %r' % (
                    uncompressed_size, size,
                )

        return section._replace(stream=uncompressed_stream, size=size) 
开发者ID:eth-sri,项目名称:debin,代码行数:35,代码来源:elffile.py

示例9: read_all_values_from_file

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def read_all_values_from_file(filename):
        with open(filename, 'rb') as infp:
            # Read the first block of data, including the first 4 bytes which tell us
            # how much of the file (which is preallocated to _INITIAL_MMAP_SIZE bytes) is occupied.
            data = infp.read(mmap.PAGESIZE)
            used = _unpack_integer(data, 0)[0]
            if used > len(data):  # Then read in the rest, if needed.
                data += infp.read(used - len(data))
        return _read_all_values(data, used) 
开发者ID:prometheus,项目名称:client_python,代码行数:11,代码来源:mmap_dict.py

示例10: test_anon

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def test_anon():
    print "  anonymous mmap.mmap(-1, PAGESIZE)..."
    m = mmap.mmap(-1, PAGESIZE)
    for x in xrange(PAGESIZE):
        verify(m[x] == '\0', "anonymously mmap'ed contents should be zero")

    for x in xrange(PAGESIZE):
        m[x] = ch = chr(x & 255)
        vereq(m[x], ch) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_mmap.py

示例11: align_to_mmap

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PAGESIZE [as 别名]
def align_to_mmap(num, round_up):
    """
    Align the given integer number to the closest page offset, which usually is 4096 bytes.

    :param round_up: if True, the next higher multiple of page size is used, otherwise
        the lower page_size will be used (i.e. if True, 1 becomes 4096, otherwise it becomes 0)
    :return: num rounded to closest page"""
    res = (num // ALLOCATIONGRANULARITY) * ALLOCATIONGRANULARITY
    if round_up and (res != num):
        res += ALLOCATIONGRANULARITY
    # END handle size
    return res 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:14,代码来源:util.py


注:本文中的mmap.PAGESIZE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。