8000 gh-80406: Finalise subinterpreters in Py_FinalizeEx() by LewisGaul · Pull Request #17575 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-80406: Finalise subinterpreters in Py_FinalizeEx() #17575

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
23af5f5
Add test suggested by ncoghlan
LewisGaul Nov 21, 2019
433663c
Finalise sub-interpreters in Py_FinalizeEx()
LewisGaul Dec 11, 2019
48e1cfc
Improve test name
LewisGaul Dec 13, 2019
0400634
Switch back to main threadstate in test_audit_subinterpreter before c…
LewisGaul Dec 13, 2019
b79649c
📜🤖 Added by blurb_it.
blurb-it[bot] Dec 14, 2019
8b1e7d9
Markups including: switch from 'finalizing' flag to 'allow_new', add …
LewisGaul Jan 21, 2020
fd6073a
Merge branch 'finalise-subinterps' of github.com:LewisGaul/cpython in…
LewisGaul Jan 21, 2020
4bbd58f
Merge branch 'master' into finalise-subinterps
LewisGaul Oct 20, 2020
1095e66
Use '_' for unused variable in test_embed.py
LewisGaul Oct 20, 2020
675285d
Fix struct position of 'allow_new' flag
LewisGaul Oct 22, 2020
8e21788
Add handling for unsupported case of calling Py_Finalize() from a sub…
LewisGaul Oct 22, 2020
606c068
Emit resource warning when calling Py_Finalize() with unfinalized sub…
LewisGaul Oct 22, 2020
e0789b0
Update Py_FinalizeEx() docs
LewisGaul Oct 22, 2020
dda99ce
Update test for resource warning when implicitly finalizing subinterp…
LewisGaul Oct 23, 2020
847e8d2
Tidy up test_finalize_subinterps() testcase
LewisGaul Oct 23, 2020
a2fb0fc
Add testcase for calling Py_Finalize() from a subinterpreter
LewisGaul Oct 23, 2020
d234528
Tweak subinterpreters still running ResourceWarning handling
LewisGaul Nov 23, 2020
46a8619
Make calling PyFinalizeEx() from a subinterpreter a Py_FatalError
LewisGaul Nov 23, 2020
c89c0e5
Acquire interpreters mutex before setting allow_new=0 in PyFinalizeEx()
LewisGaul Nov 23, 2020
c285f52
Merge remote-tracking branch 'upstream/master' into finalise-subinterps
LewisGaul Nov 23, 2020
95cbfd4
Add back in the 'interp' variable to PyFinalizeEx() to fix the build
LewisGaul Nov 23, 2020
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
10000
Diff view
Prev Previous commit
Next Next commit
Update test for resource warning when implicitly finalizing subinterp…
…reters
  • Loading branch information
LewisGaul committed Oct 23, 2020
commit dda99ced4ee2d10d38ac1df92049bf17034fdd9a
8 changes: 6 additions & 2 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ def test_finalize_subinterps(self):
bpo-36225: Subinterpreters should implicitly be torn down by
Py_Finalize().
"""
_, err = self.run_embedded_interpreter("test_finalize_subinterps")
self.assertEqual(err, "")
out, err = self.run_embedded_interpreter("test_finalize_subinterps")
if support.verbose > 1:
print()
print(out)
print(err)
self.assertIn("ResourceWarning: extra 2 interpreters", err)

def test_forced_io_encoding(self):
# Checks forced configuration of embedded interpreter IO streams
Expand Down
9 changes: 7 additions & 2 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static int test_repeated_init_and_subinterpreters(void)
static int test_finalize_subinterps(void)
{
PyThreadState *mainstate;
PyThreadState *interp_tstate;
PyGILState_STATE gilstate;
int i, j;

Expand All @@ -101,11 +102,15 @@ static int test_finalize_subinterps(void)
print_subinterp();
PyThreadState_Swap(NULL);

for (j=0; j<2; j++) {
Py_NewInterpreter();
// Create 3 subinterpreters and destroy the last one.
for (j=0; j<3; j++) {
interp_tstate = Py_NewInterpreter();
print_subinterp();
}
PyThreadState_Swap(interp_tstate);
Py_EndInterpreter(interp_tstate);

// Switch back to the main interpreter and finalize the runtime.
PyThreadState_Swap(mainstate);
print_subinterp();
PyGILState_Release(gilstate);
Expand Down
0