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
Next Next commit
refactor test_multithread_modify_file_noerror()
  • Loading branch information
uniocto committed May 5, 2021
commit 759de2b51f0c8a747505e930729c89be035b6175
11 changes: 8 additions & 3 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ def run(self):
# explicitly break the reference cycle to not leak a dangling thread
thread.exc = None

def test_multithread_modify_file(self):
def test_multithread_modify_file_noerror(self):
Comment thread
uniocto marked this conversation as resolved.
import traceback
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe PEP-8 asks for imports to be at module scope

Copy link
Copy Markdown
Contributor Author

@uniocto uniocto May 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iritkatriel
Thank you for your feedback and I'll rewrite it to support pep8.
Incidentally, pep-8 point out where I have not changed this time.
Should I also refactor the following?

> pep8 Lib/test/test_threading.py 
Lib/test/test_threading.py:45:5: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:47:5: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:49:5: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:52:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:145:41: E228 missing whitespace around modulo operator
Lib/test/test_threading.py:152:80: E501 line too long (88 > 79 characters)
Lib/test/test_threading.py:171:9: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:223:9: E265 block comment should start with '# '
Lib/test/test_threading.py:248:80: E501 line too long (80 > 79 characters)
Lib/test/test_threading.py:259:40: E261 at least two spaces before inline comment
Lib/test/test_threading.py:285:24: E261 at least two spaces before inline comment
Lib/test/test_threading.py:307:36: E261 at least two spaces before inline comment
Lib/test/test_threading.py:408:13: E128 continuation line under-indented for visual indent
Lib/test/test_threading.py:424:21: E128 continuation line under-indented for visual indent
Lib/test/test_threading.py:436:69: E231 missing whitespace after ':'
Lib/test/test_threading.py:450:26: E128 continuation line under-indented for visual indent
Lib/test/test_threading.py:458:26: E128 continuation line under-indented for visual indent
Lib/test/test_threading.py:716:9: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:733:80: E501 line too long (82 > 79 characters)
Lib/test/test_threading.py:751:9: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:769:44: E261 at least two spaces before inline comment
Lib/test/test_threading.py:838:40: E231 missing whitespace after ','
Lib/test/test_threading.py:900:13: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:902:13: E301 expected 1 blank line, found 0
Lib/test/test_threading.py:913:1: E303 too many blank lines (3)
Lib/test/test_threading.py:969:80: E501 line too long (82 > 79 characters)
Lib/test/test_threading.py:1009:80: E501 line too long (87 > 79 characters)
Lib/test/test_threading.py:1066:47: E203 whitespace before ':'
Lib/test/test_threading.py:1193:61: E703 statement ends with a semicolon
Lib/test/test_threading.py:1237:80: E501 line too long (81 > 79 characters)
Lib/test/test_threading.py:1399:80: E501 line too long (80 > 79 characters)
Lib/test/test_threading.py:1449:14: E127 continuation line over-indented for visual indent
Lib/test/test_threading.py:1450:14: E127 continuation line over-indented for visual indent
Lib/test/test_threading.py:1509:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1512:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1515:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1519:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1522:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1526:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1529:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1532:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1535:1: E302 expected 2 blank lines, found 1
Lib/test/test_threading.py:1651:17: E128 continuation line under-indented for visual indent

> pep8 Lib/test/test_linecache.py
Lib/test/test_linecache.py:229:9: E301 expected 1 blank line, found 0

def modify_file():
with open(__file__, 'a') as fp:
Comment thread
iritkatriel marked this conversation as resolved.
Outdated
Expand All @@ -1349,8 +1349,13 @@ def modify_file():
threading.Thread(target=modify_file)
for i in range(100)
]
[t.start() for t in threads]
[t.join() for t in threads]
try:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which exceptions are you trying to ignore here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing, sorry. I removed try.

for t in threads:
t.start()
for t in threads:
t.join()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you don't do

for t in threads:
    t.start()
    t.join()

?

Copy link
Copy Markdown
Contributor Author

@uniocto uniocto May 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing, sorry.
So I fixed it to your feedback.

finally:
pass


class ThreadRunFail(threading.Thread):
Expand Down