GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-120317: Lock around global state in the tokenize module by lysnikolaou · Pull Request #120318 · python/cpython Conversation
| ||||||||||||||||||||||||||||||||||||||||||||
|
This LGTM. Can you add the reproducer to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Fidget-Spinner I added more locking around global state. Reviewing each commit seprately might make it easier. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks like a refactor, so good so far.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Feedback addressed. @Fidget-Spinner I used |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Feel free to ignore the following comments if this part of the tokenizer is not perf sensitive.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
All feedback addressed. Thanks a lot for the reviews and the help @Fidget-Spinner and @erlend-aasland! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
|
|
||
| @threading_helper.requires_working_threading() | ||
| class TestTokenize(unittest.TestCase): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally: it crashes spectacularly without the fix :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -194,7 +252,13 @@ tokenizeriter_next(tokenizeriterobject *it) | |||
| } | |||
| if (it->done || type == ERRORTOKEN) { | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to protect the read? Otherwise we may get weird partial reads no?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Actually, one question here: shouldn't we be protecting all reads of the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
For example, this read is not protected, no?: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
20c7cb2 to
1c51daf
Compare
Co-authored-by: Pablo Galindo <[email protected]>
1c51daf to
ca466fa
Compare
|
After some offline discussion with @pablogsal, we decided it makes more sense to just lock around all of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| try: | ||
| r = next(it) | ||
| tokens.append(tokenize.TokenInfo._make(r)) | ||
| time.sleep(1) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we make this test faster? It's going to run on every CI job. I think we should aim for 0.1 seconds or less for these sorts of tests. (It's currently ~3 seconds).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Changed the amount of time each thread sleeps to 0.03 secs, which means that the whole test now takes about 0.1 seconds. Also verified that the test still fails without the fix and succeeds with it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@pablogsal Can you do a final review here when you have some spare cycles? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the PR and the comments and it LGTM
I also ran the tests locally in free threaded mode to confirm
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @lysnikolaou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…honGH-120318) (cherry picked from commit 8549559) Co-authored-by: Lysandros Nikolaou <[email protected]> Co-authored-by: Pablo Galindo <[email protected]>
|
GH-121841 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…-120318) (#121841) (cherry picked from commit 8549559) Co-authored-by: Lysandros Nikolaou <[email protected]> Co-authored-by: Pablo Galindo <[email protected]>
…hon#120318) Co-authored-by: Pablo Galindo <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.