Skip to content

Commit c40278e

Browse files
bombs-kimmethane
authored andcommitted
Simplify __all__ in multiprocessing (GH-6856)
1 parent 5e5bbbe commit c40278e

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Lib/multiprocessing/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
# Copy stuff from default context
2020
#
2121

22-
globals().update((name, getattr(context._default_context, name))
23-
for name in context._default_context.__all__)
24-
__all__ = context._default_context.__all__
22+
__all__ = [x for x in dir(context._default_context) if not x.startswith('_')]
23+
globals().update((name, getattr(context._default_context, name)) for name in __all__)
2524

2625
#
2726
# XXX These should not really be documented or public.

Lib/multiprocessing/context.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from . import process
66
from . import reduction
77

8-
__all__ = [] # things are copied from here to __init__.py
8+
__all__ = ()
99

1010
#
1111
# Exceptions
@@ -24,7 +24,7 @@ class AuthenticationError(ProcessError):
2424
pass
2525

2626
#
27-
# Base type for contexts
27+
# Base type for contexts. Bound methods of an instance of this type are included in __all__ of __init__.py
2828
#
2929

3030
class BaseContext(object):
@@ -261,8 +261,6 @@ def get_all_start_methods(self):
261261
else:
262262
return ['fork', 'spawn']
263263

264-
DefaultContext.__all__ = [x for x in dir(DefaultContext) if x[0] != '_']
265-
266264
#
267265
# Context types for fixed start method
268266
#

Lib/test/_test_multiprocessing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4582,6 +4582,12 @@ def test_empty(self):
45824582

45834583
proc.join()
45844584

4585+
4586+
class MiscTestCase(unittest.TestCase):
4587+
def test__all__(self):
4588+
# Just make sure names in blacklist are excluded
4589+
support.check__all__(self, multiprocessing, extra=multiprocessing.__all__,
4590+
blacklist=['SUBDEBUG', 'SUBWARNING'])
45854591
#
45864592
# Mixins
45874593
#

0 commit comments

Comments
 (0)