[Jython-checkins] jython: Allow other threads to complete after main exits (fixes #2836).
jeff.allen
jython-checkins at python.org
Tue Dec 24 06:10:10 EST 2019
https://hg.python.org/jython/rev/069db4761b37
changeset: 8314:069db4761b37
user: Jeff Allen <ja.py at farowl.co.uk>
date: Sun Dec 22 16:33:35 2019 +0000
summary:
Allow other threads to complete after main exits (fixes #2836).
We leave exiting to the JVM when a main Python program was run and ended
with good status.
files:
NEWS | 1 +
src/org/python/util/jython.java | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@
Jython 2.7.2b3
Bugs fixed
- [ 2820 ] Import fails with UnicodeDecodeError if sys.path contains invalid UTF-8 bytes
+ - [ 2836 ] Java Swing library works only in interactive jython session
Jython 2.7.2b2
Bugs fixed
diff --git a/src/org/python/util/jython.java b/src/org/python/util/jython.java
--- a/src/org/python/util/jython.java
+++ b/src/org/python/util/jython.java
@@ -674,9 +674,16 @@
}
}
- // Shut down in a tidy way
- interp.cleanup();
- exit(sts);
+ /*
+ * If we arrive here then we ran some Python code. It is possible that threads we started
+ * are still running, so if the status is currently good, just return into the JVM. (This
+ * exits with good status if nothing goes wrong subsequently.)
+ */
+ if (sts != Status.OK) {
+ // Something went wrong running Python code: shut down in a tidy way.
+ interp.cleanup();
+ exit(sts);
+ }
}
/**
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list