diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-08 21:17:16 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-08 21:17:16 (GMT) |
commit | bcd5cbe01ef4306a82f85d0500f9a9f04113f804 (patch) | |
tree | a9753988bcb56f924a12dac12dc09ad5e54b3119 /Lib/test/test_hashlib.py | |
parent | 5bad41eefc9f80298bb1abe00a5475be8b015c57 (diff) | |
download | cpython-bcd5cbe01ef4306a82f85d0500f9a9f04113f804.zip cpython-bcd5cbe01ef4306a82f85d0500f9a9f04113f804.tar.gz cpython-bcd5cbe01ef4306a82f85d0500f9a9f04113f804.tar.bz2 |
Issue #4751: hashlib now releases the GIL when hashing large buffers
(with a hardwired threshold of 2048 bytes), allowing better parallelization
on multi-CPU systems. Contributed by Lukas Lueg (ebfe) and Victor Stinner.
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r-- | Lib/test/test_hashlib.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 10fe3be..e69c704 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -198,6 +198,19 @@ class HashLibTestCase(unittest.TestCase): "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb"+ "de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b") + def test_gil(self): + # Check things work fine with an input larger than the size required + # for multithreaded operation (which is hardwired to 2048). + gil_minsize = 2048 + + m = hashlib.md5() + m.update(b'1') + m.update(b'#' * gil_minsize) + m.update(b'1') + self.assertEquals(m.hexdigest(), 'cb1e1a2cbc80be75e19935d621fb9b21') + + m = hashlib.md5(b'x' * gil_minsize) + self.assertEquals(m.hexdigest(), 'cfb767f225d58469c5de3632a8803958') def test_main(): support.run_unittest(HashLibTestCase) |