Message10683

Author stefan.richthofer
Recipients nickmbailey, stefan.richthofer, zyasoft
Date 2016-02-02.05:28:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454390908.45.0.305159439205.issue2457@psf.upfronthosting.co.za>
In-reply-to
Content
This can likely be fixed by adjusting org.python.modules._io.Closer a bit (see our discussion at https://github.com/jythontools/jython/pull/30):

AtomicBoolean dismissed = new AtomicBoolean();

public void dismiss() {
  if (dismissed.compareAndSet(false, true))
    sys.unregisterCloser(this);
}

public synchronized Void call() {
  if (dismissed.compareAndSet(false, true)) {
    ...
  }
}


Note that dismiss does not need to be synchronized any more, still maintaining the old behavior. If Nick can confirm that this solves the issue, we can maybe get it already into beta 3 right now.
Later we should add a note to documentation of PySystemState.registerCloser and related API that Callable-implementors must not introduce their own locks because of deadlock risk. They rather should lock on PySystemStateCloser.class or use non-blocking locks like this AtomicBoolean variant. However I'd add this doc-stuff later for the RC.
History
Date User Action Args
2016-02-02 05:28:28stefan.richthofersetmessageid: <1454390908.45.0.305159439205.issue2457@psf.upfronthosting.co.za>
2016-02-02 05:28:28stefan.richthofersetrecipients: + stefan.richthofer, zyasoft, nickmbailey
2016-02-02 05:28:28stefan.richthoferlinkissue2457 messages
2016-02-02 05:28:28stefan.richthofercreate