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
def __setstate__(self, state): if sys.version_info < (3, 4): h, kind, maxvalue, name = state self._semlock = SemLockC(h, kind, maxvalue, name=name) else: self._semlock = SemLockC._rebuild(*state) util.debug('recreated blocker with handle %r and name %s' % (state[0], state[3])) self._make_methods()
def test_semaphore_rebuild(self): import sys if sys.platform == 'win32': from _multiprocessing import SemLock def sem_unlink(*args): pass else: from _multiprocessing import SemLock, sem_unlink kind = self.SEMAPHORE value = 1 maxvalue = 1 sem = SemLock(kind, value, maxvalue, "4.2", unlink=False) try: sem2 = SemLock._rebuild(-1, kind, value, "4.2") #assert sem.handle != sem2.handle---even though they come # from different calls to sem_open(), on Linux at least, # they are the same pointer sem2 = SemLock._rebuild(sem.handle, kind, value, None) assert sem.handle == sem2.handle finally: sem_unlink("4.2")
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()
def __setstate__(self, state): self._semlock = _SemLock._rebuild(*state) util.debug( f'recreated blocker with handle {state[0]!r} and name "{state[3]}"' ) self._make_methods()
def __setstate__(self, state): reader, writer = state self._reader = SemLock._rebuild(*reader) self._writer = SemLock._rebuild(*writer)