🌐 AI搜索 & 代理 主页
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use ThreadPoolExecutor
  • Loading branch information
DinoV committed May 6, 2024
commit db233a3bd177f5af30b781057bb8ca48436e203d
12 changes: 5 additions & 7 deletions Lib/test/test_free_threading/test_type.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import unittest

from concurrent.futures import ThreadPoolExecutor
from threading import Thread
from unittest import TestCase

from test.support import threading_helper, import_helper


multiprocessing_dummy = import_helper.import_module('multiprocessing.dummy')
Pool = multiprocessing_dummy.Pool

NTHREADS = 6
BOTTOM = 0
Expand Down Expand Up @@ -36,11 +35,10 @@ def write(id0):
A.attr = x


with Pool(NTHREADS) as pool:
pool.apply_async(read, (1,))
pool.apply_async(write, (1,))
pool.close()
pool.join()
with ThreadPoolExecutor(NTHREADS) as pool:
pool.submit(read, (1,))
pool.submit(write, (1,))
pool.shutdown(wait=True)

def test_attr_cache_consistency(self):
class C:
Expand Down