File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -79,19 +79,27 @@ def __del__(self):
7979 # making sure child processess are cleaned before ResourceTracker
8080 # gets destructed.
8181 # see https://github.com/python/cpython/issues/88887
82- self ._stop ()
82+ try :
83+ self ._stop ()
84+ except AttributeError :
85+ # AttributeError is likely caused by module teardown
86+ # > __del__() can be executed during interpreter shutdown. As a
87+ # > consequence, the global variables it needs to access (including
88+ # > other modules) may already have been deleted or set to None.
89+ # see https://docs.python.org/3/reference/datamodel.html#object.__del__
90+ pass
8391
8492 def _stop (self ):
8593 with self ._lock :
86- if self ._pid is None :
87- return
8894 # This should not happen (_stop() isn't called by a finalizer)
8995 # but we check for it anyway.
9096 if self ._lock ._recursion_count () > 1 :
9197 return self ._reentrant_call_error ()
9298 if self ._fd is None :
9399 # not running
94100 return
101+ if self ._pid is None :
102+ return
95103
96104 # closing the "alive" file descriptor stops main()
97105 os .close (self ._fd )
You can’t perform that action at this time.
0 commit comments