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


Python _multiprocessing.SemLock类代码示例

本文整理汇总了Python中_multiprocessing.SemLock的典型用法代码示例。如果您正苦于以下问题:Python SemLock类的具体用法?Python SemLock怎么用?Python SemLock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_semaphore_contextmanager

    def test_semaphore_contextmanager(self):
        from _multiprocessing import SemLock
        kind = self.SEMAPHORE
        value = 1
        maxvalue = 1
        sem = SemLock(kind, value, maxvalue)

        with sem:
            assert sem._count() == 1
        assert sem._count() == 0
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:test_semaphore.py

示例2: test_semaphore_rebuild

    def test_semaphore_rebuild(self):
        from _multiprocessing import SemLock
        kind = self.SEMAPHORE
        value = 1
        maxvalue = 1
        sem = SemLock(kind, value, maxvalue)

        sem2 = SemLock._rebuild(sem.handle, kind, value)
        assert sem.handle == sem2.handle
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:test_semaphore.py

示例3: __init__

 def __init__(self, value=1, *, ctx):
     SemLock.__init__(self, SEMAPHORE, value, value, ctx=ctx)
开发者ID:0jpq0,项目名称:kbengine,代码行数:2,代码来源:synchronize.py

示例4: __init__

 def __init__(self):
     SemLock.__init__(self, SEMAPHORE, 1, 1)
开发者ID:webiumsk,项目名称:WOT-0.9.12-CT,代码行数:2,代码来源:synchronize.py

示例5: __setstate__

 def __setstate__(self, state):
     self._semlock = _SemLock._rebuild(*state)
     util.debug('recreated blocker with handle %r and name "%s"'
                % (state[0], state[3]))
     self._make_methods()
开发者ID:ELVIS-Project,项目名称:music21,代码行数:5,代码来源:synchronize.py

示例6: test_recursive

    def test_recursive(self):
        from _multiprocessing import SemLock
        kind = self.RECURSIVE
        value = 1
        maxvalue = 1
        sem = SemLock(kind, value, maxvalue)

        sem.acquire()
        sem.release()
        assert sem._count() == 0
        sem.acquire()
        sem.release()

        # now recursively
        sem.acquire()
        sem.acquire()
        assert sem._count() == 2
        sem.release()
        sem.release()
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:19,代码来源:test_semaphore.py

示例7: test_semaphore

    def test_semaphore(self):
        from _multiprocessing import SemLock
        import sys
        assert SemLock.SEM_VALUE_MAX > 10

        kind = self.SEMAPHORE
        value = 1
        maxvalue = 1
        sem = SemLock(kind, value, maxvalue)
        assert sem.kind == kind
        assert sem.maxvalue == maxvalue
        assert isinstance(sem.handle, (int, long))

        assert sem._count() == 0
        if sys.platform == 'darwin':
            raises(NotImplementedError, 'sem._get_value()')
        else:
            assert sem._get_value() == 1
        assert sem._is_zero() == False
        sem.acquire()
        assert sem._is_mine()
        assert sem._count() == 1
        if sys.platform == 'darwin':
            raises(NotImplementedError, 'sem._get_value()')
        else:
            assert sem._get_value() == 0
        assert sem._is_zero() == True
        sem.release()
        assert sem._count() == 0

        sem.acquire()
        sem._after_fork()
        assert sem._count() == 0
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:33,代码来源:test_semaphore.py

示例8: __setstate__

 def __setstate__(self, state):
     reader, writer = state
     self._reader = SemLock._rebuild(*reader)
     self._writer = SemLock._rebuild(*writer)
开发者ID:sdiehl,项目名称:numpush,代码行数:4,代码来源:shmem_sync.py


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