Skip to content

Commit fc4df5d

Browse files
committed
add test_multithread_modify_file()
1 parent fc1f92d commit fc4df5d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_threading.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,20 @@ def run(self):
13381338
# explicitly break the reference cycle to not leak a dangling thread
13391339
thread.exc = None
13401340

1341+
def test_multithread_modify_file(self):
1342+
import traceback
1343+
def modify_file():
1344+
with open(__file__, 'a') as fp:
1345+
fp.write(' ')
1346+
traceback.format_stack()
1347+
1348+
threads = [
1349+
threading.Thread(target=modify_file)
1350+
for i in range(100)
1351+
]
1352+
[t.start() for t in threads]
1353+
[t.join() for t in threads]
1354+
13411355

13421356
class ThreadRunFail(threading.Thread):
13431357
def run(self):
@@ -1634,3 +1648,4 @@ def run_last():
16341648

16351649
if __name__ == "__main__":
16361650
unittest.main()
1651+

0 commit comments

Comments
 (0)