Ref : https://github.com/python/cpython/pull/25174

https://github.com/localstack/localstack/blob/5a5edcd9d9ccbd6a56f23d71e3a1131b8c814996/localstack/utils/common.py#L324
continue
                if hasattr(thread, 'kill'):
                    thread.kill()
                    continue
                thread.stop(quiet=quiet)
            except Exception as e:
                print(e)
    for proc in TMP_PROCESSES:
        try:
            print_debug('[shutdown] Cleaning up process: %s' % proc, debug)
            kill_process_tree(proc.pid)
            
        except Exception as e:
            print(e)
    
    try:
        import asyncio
        for task in asyncio.all_tasks():
            try:
                print_debug('[shutdown] Canceling asyncio task: %s' % task, debug)
                task.cancel()
            except Exception as e:
                print(e)
    except Exception:
        pass
    print_debug('[shutdown] Done cleaning up threads / processes / tasks', debug)
    
    clear_list(TMP_THREADS)
    clear_list(TMP_PROCESSES)
def kill_process_tree(parent_pid):