Skip to content

Commit 378be65

Browse files
committed
JythonReferenceCleaner: reformat comments
This avoids them breaking the 80 character line limit, and makes them a little nicer to read (IMHO).
1 parent dacf3e9 commit 378be65

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/main/java/org/scijava/plugins/scripting/jython/JythonReferenceCleaner.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public synchronized void queueCleanup(final JythonScriptEngine engine,
6868
// to use PhantomReferences because the "scope" of a script extends
6969
// beyond its eval method - a consumer may still want to inspect
7070
// the state of variables after evaluation.
71-
// By using PhantomReferences we are saying that the scope of
71+
//
72+
// By using PhantomReferences we are saying that the scope of
7273
// script evaluation equals the lifetime of the ScriptEngine.
7374
phantomReferences.add(new JythonEnginePhantomReference(engine, queue));
7475

@@ -77,6 +78,7 @@ public synchronized void queueCleanup(final JythonScriptEngine engine,
7778
// threads that would need to be interrupted - instead only starting
7879
// threads running when there is actually a PhantomReference that
7980
// will eventually be enqueued.
81+
//
8082
// Here we check if there is already a polling thread in operation -
8183
// if not, we start a new thread.
8284
if (phantomReferences.size() == 1) {
@@ -144,19 +146,24 @@ public void cleanup() {
144146

145147
// NB: This method for cleaning up local variables was taken from:
146148
// http://python.6.x6.nabble.com/Cleaning-up-PythonInterpreter-object-td1777184.html
147-
// Because Python is an interpreted language, when a Python script creates new
148-
// variables they stick around in a static org.python.core.PySystemState variable
149-
// (defaultSystemState) the org.python.core.Py class.
150-
// Thus an implicit static state is created by script evaluation, so we must manually
151-
// clean up local variables known to the interpreter when the scope of an executed
152-
// script is over.
153-
// See original bug report for the memory leak that prompted this solution:
149+
//
150+
// Because Python is an interpreted language, when a Python script
151+
// creates new variables they stick around in a static
152+
// org.python.core.PySystemState variable (defaultSystemState)
153+
// the org.python.core.Py class.
154+
//
155+
// Thus an implicit static state is created by script evaluation,
156+
// so we must manually clean up local variables known to the
157+
// interpreter when the scope of an executed script is over.
158+
//
159+
// See original bug report for the leak that prompted this solution:
154160
// http://fiji.sc/bugzilla/show_bug.cgi?id=1203
161+
155162
final PyObject locals = interp.getLocals();
156163
for (final PyObject item : locals.__iter__().asIterable()) {
157164
final String localVar = item.toString();
158-
// Ignore __name__ and __doc__ variables, which are special and known not
159-
// to be local variables created by evaluation.
165+
// Ignore __name__ and __doc__ variables, which are special
166+
// and known not to be local variables created by evaluation.
160167
if (!localVar.contains("__name__") && !localVar.contains("__doc__")) {
161168
// Build list of variables to clean
162169
scriptLocals.add(item.toString());

0 commit comments

Comments
 (0)