diff --git a/Lib/multiprocessing/dummy/__init__.py b/Lib/multiprocessing/dummy/__init__.py index 403f5e5198..fc01ecfa32 100644 --- a/Lib/multiprocessing/dummy/__init__.py +++ b/Lib/multiprocessing/dummy/__init__.py @@ -21,6 +21,7 @@ import threading import sys import weakref import array +import warnings from .connection import Pipe from threading import Lock, RLock, Semaphore, BoundedSemaphore @@ -39,6 +40,7 @@ class DummyProcess(threading.Thread): self._children = weakref.WeakKeyDictionary() self._start_called = False self._parent = current_process() + self._joined = False def start(self): if self._parent is not current_process(): @@ -50,6 +52,15 @@ class DummyProcess(threading.Thread): self._parent._children[self] = None threading.Thread.start(self) + def join(self): + self._joined = True + super().join() + + def __del__(self, _warn=warnings.warn): + if not self._joined: + _warn("thread %r not joined" % self, + ResourceWarning, source=self) + @property def exitcode(self): if self._start_called and not self.is_alive(): diff --git a/Lib/multiprocessing/popen_fork.py b/Lib/multiprocessing/popen_fork.py index 685e8daf77..4e0285b9d3 100644 --- a/Lib/multiprocessing/popen_fork.py +++ b/Lib/multiprocessing/popen_fork.py @@ -1,5 +1,6 @@ import os import signal +import time from . import util diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py index cd592d0bdf..6cbe80b8f5 100644 --- a/Lib/multiprocessing/process.py +++ b/Lib/multiprocessing/process.py @@ -18,6 +18,7 @@ import sys import signal import itertools import threading +import warnings from _weakrefset import WeakSet # @@ -160,6 +161,11 @@ class BaseProcess(object): _children.discard(self) return False + def __del__(self, _warn=warnings.warn): + if self._popen is not None: + _warn("process %r is still running" % self, + ResourceWarning, source=self) + def close(self): ''' Close the Process object.