Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Side by Side Diff: Lib/test/test_multiprocessing.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_mmap.py ('k') | Lib/test/test_optparse.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 # 3 #
4 # Unit tests for the multiprocessing package 4 # Unit tests for the multiprocessing package
5 # 5 #
6 6
7 import unittest 7 import unittest
8 import queue as pyqueue 8 import queue as pyqueue
9 import time 9 import time
10 import io 10 import io
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 if len(blocks) > maxblocks: 1714 if len(blocks) > maxblocks:
1715 i = random.randrange(maxblocks) 1715 i = random.randrange(maxblocks)
1716 del blocks[i] 1716 del blocks[i]
1717 1717
1718 # get the heap object 1718 # get the heap object
1719 heap = multiprocessing.heap.BufferWrapper._heap 1719 heap = multiprocessing.heap.BufferWrapper._heap
1720 1720
1721 # verify the state of the heap 1721 # verify the state of the heap
1722 all = [] 1722 all = []
1723 occupied = 0 1723 occupied = 0
1724 heap._lock.acquire()
1725 self.addCleanup(heap._lock.release)
1726 for L in list(heap._len_to_seq.values()): 1724 for L in list(heap._len_to_seq.values()):
1727 for arena, start, stop in L: 1725 for arena, start, stop in L:
1728 all.append((heap._arenas.index(arena), start, stop, 1726 all.append((heap._arenas.index(arena), start, stop,
1729 stop-start, 'free')) 1727 stop-start, 'free'))
1730 for arena, start, stop in heap._allocated_blocks: 1728 for arena, start, stop in heap._allocated_blocks:
1731 all.append((heap._arenas.index(arena), start, stop, 1729 all.append((heap._arenas.index(arena), start, stop,
1732 stop-start, 'occupied')) 1730 stop-start, 'occupied'))
1733 occupied += (stop-start) 1731 occupied += (stop-start)
1734 1732
1735 all.sort() 1733 all.sort()
1736 1734
1737 for i in range(len(all)-1): 1735 for i in range(len(all)-1):
1738 (arena, start, stop) = all[i][:3] 1736 (arena, start, stop) = all[i][:3]
1739 (narena, nstart, nstop) = all[i+1][:3] 1737 (narena, nstart, nstop) = all[i+1][:3]
1740 self.assertTrue((arena != narena and nstart == 0) or 1738 self.assertTrue((arena != narena and nstart == 0) or
1741 (stop == nstart)) 1739 (stop == nstart))
1742
1743 def test_free_from_gc(self):
1744 # Check that freeing of blocks by the garbage collector doesn't deadlock
1745 # (issue #12352).
1746 # Make sure the GC is enabled, and set lower collection thresholds to
1747 # make collections more frequent (and increase the probability of
1748 # deadlock).
1749 if not gc.isenabled():
1750 gc.enable()
1751 self.addCleanup(gc.disable)
1752 thresholds = gc.get_threshold()
1753 self.addCleanup(gc.set_threshold, *thresholds)
1754 gc.set_threshold(10)
1755
1756 # perform numerous block allocations, with cyclic references to make
1757 # sure objects are collected asynchronously by the gc
1758 for i in range(5000):
1759 a = multiprocessing.heap.BufferWrapper(1)
1760 b = multiprocessing.heap.BufferWrapper(1)
1761 # circular references
1762 a.buddy = b
1763 b.buddy = a
1764 1740
1765 # 1741 #
1766 # 1742 #
1767 # 1743 #
1768 1744
1769 class _Foo(Structure): 1745 class _Foo(Structure):
1770 _fields_ = [ 1746 _fields_ = [
1771 ('x', c_int), 1747 ('x', c_int),
1772 ('y', c_double) 1748 ('y', c_double)
1773 ] 1749 ]
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 ManagerMixin.pool.terminate() 2208 ManagerMixin.pool.terminate()
2233 ManagerMixin.manager.shutdown() 2209 ManagerMixin.manager.shutdown()
2234 2210
2235 del ProcessesMixin.pool, ThreadsMixin.pool, ManagerMixin.pool 2211 del ProcessesMixin.pool, ThreadsMixin.pool, ManagerMixin.pool
2236 2212
2237 def main(): 2213 def main():
2238 test_main(unittest.TextTestRunner(verbosity=2).run) 2214 test_main(unittest.TextTestRunner(verbosity=2).run)
2239 2215
2240 if __name__ == '__main__': 2216 if __name__ == '__main__':
2241 main() 2217 main()
OLDNEW
« no previous file with comments | « Lib/test/test_mmap.py ('k') | Lib/test/test_optparse.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+