當前位置: 首頁>>代碼示例>>Python>>正文


Python util.ForkAwareThreadLock方法代碼示例

本文整理匯總了Python中multiprocessing.util.ForkAwareThreadLock方法的典型用法代碼示例。如果您正苦於以下問題:Python util.ForkAwareThreadLock方法的具體用法?Python util.ForkAwareThreadLock怎麽用?Python util.ForkAwareThreadLock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在multiprocessing.util的用法示例。


在下文中一共展示了util.ForkAwareThreadLock方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_flags

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import ForkAwareThreadLock [as 別名]
def test_flags(self):
        import json, subprocess
        # start child process using unusual flags
        prog = ('from test.test_multiprocessing import TestFlags; ' +
                'TestFlags.run_in_child()')
        data = subprocess.check_output(
            [sys.executable, '-E', '-B', '-O', '-c', prog])
        child_flags, grandchild_flags = json.loads(data.decode('ascii'))
        self.assertEqual(child_flags, grandchild_flags)

#
# Issue #17555: ForkAwareThreadLock
# 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_multiprocessing.py

示例2: test_lock

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import ForkAwareThreadLock [as 別名]
def test_lock(self):
        r, w = multiprocessing.Pipe(False)
        l = util.ForkAwareThreadLock()
        old_size = len(util._afterfork_registry)
        p = multiprocessing.Process(target=self.child, args=(5, w))
        p.start()
        new_size = r.recv()
        p.join()
        self.assertLessEqual(new_size, old_size)

#
# Issue #17097: EINTR should be ignored by recv(), send(), accept() etc
# 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_multiprocessing.py

示例3: test_lock

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import ForkAwareThreadLock [as 別名]
def test_lock(self):
        r, w = multiprocessing.Pipe(False)
        l = util.ForkAwareThreadLock()
        old_size = len(util._afterfork_registry)
        p = multiprocessing.Process(target=self.child, args=(5, w))
        p.start()
        new_size = r.recv()
        p.join()
        self.assertLessEqual(new_size, old_size)

#
#
# 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:15,代碼來源:test_multiprocessing.py

示例4: test_noforkbomb

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import ForkAwareThreadLock [as 別名]
def test_noforkbomb(self):
        sm = multiprocessing.get_start_method()
        name = os.path.join(os.path.dirname(__file__), 'mp_fork_bomb.py')
        if sm != 'fork':
            rc, out, err = test.support.script_helper.assert_python_failure(name, sm)
            self.assertEqual(out, b'')
            self.assertIn(b'RuntimeError', err)
        else:
            rc, out, err = test.support.script_helper.assert_python_ok(name, sm)
            self.assertEqual(out.rstrip(), b'123')
            self.assertEqual(err, b'')

#
# Issue #17555: ForkAwareThreadLock
# 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:17,代碼來源:_test_multiprocessing.py

示例5: test_lock

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import ForkAwareThreadLock [as 別名]
def test_lock(self):
        r, w = multiprocessing.Pipe(False)
        l = util.ForkAwareThreadLock()
        old_size = len(util._afterfork_registry)
        p = multiprocessing.Process(target=self.child, args=(5, w))
        p.start()
        w.close()
        new_size = r.recv()
        p.join(timeout=5)
        self.assertLessEqual(new_size, old_size)

#
# Check that non-forked child processes do not inherit unneeded fds/handles
# 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:16,代碼來源:_test_multiprocessing.py

示例6: test_noforkbomb

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import ForkAwareThreadLock [as 別名]
def test_noforkbomb(self):
        sm = multiprocessing.get_start_method()
        name = os.path.join(os.path.dirname(__file__), 'mp_fork_bomb.py')
        if sm != 'fork':
            rc, out, err = test.script_helper.assert_python_failure(name, sm)
            self.assertEqual(out, b'')
            self.assertIn(b'RuntimeError', err)
        else:
            rc, out, err = test.script_helper.assert_python_ok(name, sm)
            self.assertEqual(out.rstrip(), b'123')
            self.assertEqual(err, b'')

#
# Issue #17555: ForkAwareThreadLock
# 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:17,代碼來源:_test_multiprocessing.py


注:本文中的multiprocessing.util.ForkAwareThreadLock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。