-
Notifications
You must be signed in to change notification settings - Fork 229
Add no-GIL interpreter support #641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
clin1234
wants to merge
14
commits into
msgpack:main
Choose a base branch
from
clin1234:nogil
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−8
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6ced817
Add no-GIL interpreter support
clin1234 75cdd03
Exclude PYTHON_GIL=0 for now
clin1234 cafe4f0
Lint
clin1234 3cc2a38
Exclude PYTHON_GIL for now
clin1234 61aa23f
Update .github/workflows/wheel.yml
clin1234 7b7b1bf
Merge branch 'main' into nogil
clin1234 d965025
Fix extremely silly typo
clin1234 bf58057
Drop 3.8 support in test.yml
clin1234 42f4cba
Drop pytest-run-parallel as test requirement in requirements.txt
clin1234 d0797bd
Separate C extension and fallback tests for GIL and no-GIL interpreters
clin1234 79e5de1
Work around Windows wonkiness
clin1234 9a7659f
Fix minor YAML oops in .github/workflows/test.yml
clin1234 e0e9b12
Fix minor YAML oops in .github/workflows/test.yml
clin1234 ccfd254
Drop spurious multhreading test
clin1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Cython~=3.1.2 | ||
#pytest-run-parallel[psutil] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
import threading | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
from msgpack import Packer | ||
|
||
|
||
def run_threaded( | ||
func, | ||
num_threads=8, | ||
pass_count=False, | ||
pass_barrier=False, | ||
outer_iterations=1, | ||
prepare_args=None, | ||
): | ||
"""Runs a function many times in parallel""" | ||
for _ in range(outer_iterations): | ||
with ThreadPoolExecutor(max_workers=num_threads) as tpe: | ||
if prepare_args is None: | ||
args = [] | ||
else: | ||
args = prepare_args() | ||
if pass_barrier: | ||
barrier = threading.Barrier(num_threads) | ||
args.append(barrier) | ||
if pass_count: | ||
all_args = [(func, i, *args) for i in range(num_threads)] | ||
else: | ||
all_args = [(func, *args) for i in range(num_threads)] | ||
try: | ||
futures = [] | ||
for arg in all_args: | ||
futures.append(tpe.submit(*arg)) | ||
finally: | ||
if len(futures) < num_threads and pass_barrier: | ||
barrier.abort() | ||
for f in futures: | ||
f.result() | ||
|
||
|
||
def test_multithread_packing(): | ||
output = [] | ||
test_data = "abcd" * 10_000_000 | ||
packer = Packer() | ||
|
||
def closure(b): | ||
data = packer.pack(test_data) | ||
output.append(data) | ||
b.wait() | ||
|
||
run_threaded(closure, num_threads=10, pass_barrier=True, pass_count=False) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're using
allow-prereleases: true
, you can actually just make this"3.14"
and"3.14t"
—actions/setup-python
will use the prereleases while it has to, and automatically switch to the released versions once they're available.