@@ -439,6 +439,36 @@ def _test_stderr_flush(cls, testfn):
439439 1 / 0 # MARKER
440440
441441
442+ @classmethod
443+ def _test_sys_exit (cls , reason , testfn ):
444+ sys .stderr = open (testfn , 'w' )
445+ sys .exit (reason )
446+
447+ def test_sys_exit (self ):
448+ # See Issue 13854
449+ if self .TYPE == 'threads' :
450+ return
451+
452+ testfn = test .support .TESTFN
453+ self .addCleanup (test .support .unlink , testfn )
454+
455+ for reason , code in (([1 , 2 , 3 ], 1 ), ('ignore this' , 0 )):
456+ p = self .Process (target = self ._test_sys_exit , args = (reason , testfn ))
457+ p .daemon = True
458+ p .start ()
459+ p .join (5 )
460+ self .assertEqual (p .exitcode , code )
461+
462+ with open (testfn , 'r' ) as f :
463+ self .assertEqual (f .read ().rstrip (), str (reason ))
464+
465+ for reason in (True , False , 8 ):
466+ p = self .Process (target = sys .exit , args = (reason ,))
467+ p .daemon = True
468+ p .start ()
469+ p .join (5 )
470+ self .assertEqual (p .exitcode , reason )
471+
442472#
443473#
444474#
@@ -1342,6 +1372,18 @@ def test_terminate(self):
13421372 join ()
13431373 self .assertLess (join .elapsed , 0.5 )
13441374
1375+ def test_empty_iterable (self ):
1376+ # See Issue 12157
1377+ p = self .Pool (1 )
1378+
1379+ self .assertEqual (p .map (sqr , []), [])
1380+ self .assertEqual (list (p .imap (sqr , [])), [])
1381+ self .assertEqual (list (p .imap_unordered (sqr , [])), [])
1382+ self .assertEqual (p .map_async (sqr , []).get (), [])
1383+
1384+ p .close ()
1385+ p .join ()
1386+
13451387def raising ():
13461388 raise KeyError ("key" )
13471389
@@ -2487,7 +2529,7 @@ class ProcessesMixin(object):
24872529 'Queue' , 'Lock' , 'RLock' , 'Semaphore' , 'BoundedSemaphore' ,
24882530 'Condition' , 'Event' , 'Value' , 'Array' , 'RawValue' ,
24892531 'RawArray' , 'current_process' , 'active_children' , 'Pipe' ,
2490- 'connection' , 'JoinableQueue'
2532+ 'connection' , 'JoinableQueue' , 'Pool'
24912533 )))
24922534
24932535testcases_processes = create_test_cases (ProcessesMixin , type = 'processes' )
@@ -2501,7 +2543,7 @@ class ManagerMixin(object):
25012543 locals ().update (get_attributes (manager , (
25022544 'Queue' , 'Lock' , 'RLock' , 'Semaphore' , 'BoundedSemaphore' ,
25032545 'Condition' , 'Event' , 'Value' , 'Array' , 'list' , 'dict' ,
2504- 'Namespace' , 'JoinableQueue'
2546+ 'Namespace' , 'JoinableQueue' , 'Pool'
25052547 )))
25062548
25072549testcases_manager = create_test_cases (ManagerMixin , type = 'manager' )
@@ -2515,7 +2557,7 @@ class ThreadsMixin(object):
25152557 'Queue' , 'Lock' , 'RLock' , 'Semaphore' , 'BoundedSemaphore' ,
25162558 'Condition' , 'Event' , 'Value' , 'Array' , 'current_process' ,
25172559 'active_children' , 'Pipe' , 'connection' , 'dict' , 'list' ,
2518- 'Namespace' , 'JoinableQueue'
2560+ 'Namespace' , 'JoinableQueue' , 'Pool'
25192561 )))
25202562
25212563testcases_threads = create_test_cases (ThreadsMixin , type = 'threads' )
0 commit comments