Message10684
I can confirm that the following patch also appears to fix the issue.
diff --git a/src/org/python/modules/_io/Closer.java b/src/org/python/modules/_io/Closer.java
index 3aec84f..d4a8a8e 100644
--- a/src/org/python/modules/_io/Closer.java
+++ b/src/org/python/modules/_io/Closer.java
@@ -3,6 +3,7 @@ package org.python.modules._io;
import java.lang.ref.WeakReference;
import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.python.core.PyObject;
import org.python.core.PySystemState;
@@ -32,9 +33,12 @@ class Closer<C extends PyIOBase> implements Callable<Void> {
/** Interpreter state that will call {@link #call()} on shutdown. */
protected PySystemState sys;
+ private AtomicBoolean dismissed;
+
public Closer(C toClose, PySystemState sys) {
this.client = new WeakReference<C>(toClose);
this.sys = sys;
+ this.dismissed = new AtomicBoolean(false);
sys.registerCloser(this);
}
@@ -42,10 +46,9 @@ class Closer<C extends PyIOBase> implements Callable<Void> {
* Tell the Closer that its services are no longer required. This unhooks it from the shutdown
* list. Repeated calls are allowed but only the first has any effect.
*/
- public synchronized void dismiss() {
- if (sys != null) {
+ public void dismiss() {
+ if (dismissed.compareAndSet(false, true)) {
sys.unregisterCloser(this);
- sys = null;
}
}
@@ -55,9 +58,8 @@ class Closer<C extends PyIOBase> implements Callable<Void> {
*/
@Override
public synchronized Void call() {
- if (sys != null) {
+ if (dismissed.compareAndSet(false, true)) {
// This will prevent repeated work and dismiss() manipulating the list of closers
- sys = null;
// Call close on the client (if it still exists)
C toClose = client.get();
if (toClose != null) {
@@ -66,4 +68,4 @@ class Closer<C extends PyIOBase> implements Callable<Void> {
}
return null;
}
-}
\ No newline at end of file
+} |
|
Date |
User |
Action |
Args |
2016-02-02 05:39:12 | nickmbailey | set | messageid: <1454391552.08.0.528176296701.issue2457@psf.upfronthosting.co.za> |
2016-02-02 05:39:12 | nickmbailey | set | recipients:
+ nickmbailey, zyasoft, stefan.richthofer |
2016-02-02 05:39:12 | nickmbailey | link | issue2457 messages |
2016-02-02 05:39:11 | nickmbailey | create | |
|