[Jython-checkins] jython: Add ContextManager __enter__/__exit__ methods to PyLock
jim.baker
jython-checkins at python.org
Wed Mar 14 19:28:53 CET 2012
http://hg.python.org/jython/rev/b4b0aa148654
changeset: 6360:b4b0aa148654
parent: 6358:d6e314e5ea02
user: Jim Baker <jbaker at zyasoft.com>
date: Wed Mar 14 11:28:08 2012 -0700
summary:
Add ContextManager __enter__/__exit__ methods to PyLock
files:
.idea/misc.xml | 66 ---
.idea/workspace.xml | 173 +++++++++-
src/org/python/modules/thread/PyLock.java | 17 +-
3 files changed, 183 insertions(+), 73 deletions(-)
diff --git a/.idea/misc.xml b/.idea/misc.xml
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -146,71 +146,5 @@
<Port>5050</Port>
</configuration>
</component>
- <component name="SvnConfiguration" maxAnnotateRevisions="500">
- <option name="USER" value="" />
- <option name="PASSWORD" value="" />
- <option name="mySSHConnectionTimeout" value="30000" />
- <option name="mySSHReadTimeout" value="30000" />
- <option name="LAST_MERGED_REVISION" />
- <option name="MERGE_DRY_RUN" value="false" />
- <option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
- <option name="UPDATE_LOCK_ON_DEMAND" value="false" />
- <option name="IGNORE_SPACES_IN_MERGE" value="false" />
- <option name="DETECT_NESTED_COPIES" value="true" />
- <option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
- <option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
- <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
- <option name="FORCE_UPDATE" value="false" />
- <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
- </component>
- <component name="masterDetails">
- <states>
- <state key="GlobalLibrariesConfigurable.UI">
- <settings>
- <splitter-proportions>
- <option name="proportions">
- <list>
- <option value="0.2" />
- </list>
- </option>
- </splitter-proportions>
- </settings>
- </state>
- <state key="JdkListConfigurable.UI">
- <settings>
- <splitter-proportions>
- <option name="proportions">
- <list>
- <option value="0.2" />
- </list>
- </option>
- </splitter-proportions>
- </settings>
- </state>
- <state key="ProjectJDKs.UI">
- <settings>
- <last-edited>1.7</last-edited>
- <splitter-proportions>
- <option name="proportions">
- <list>
- <option value="0.20000002" />
- </list>
- </option>
- </splitter-proportions>
- </settings>
- </state>
- <state key="ProjectLibrariesConfigurable.UI">
- <settings>
- <splitter-proportions>
- <option name="proportions">
- <list>
- <option value="0.2" />
- </list>
- </option>
- </splitter-proportions>
- </settings>
- </state>
- </states>
- </component>
</project>
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -18,6 +18,21 @@
<disable_hints />
</component>
<component name="DebuggerManager">
+ <line_breakpoints>
+ <breakpoint url="file://$PROJECT_DIR$/src/org/python/modules/thread/PyLock.java" line="5" class="org.python.modules.thread.PyLock" package="org.python.modules.thread">
+ <option name="ENABLED" value="true" />
+ <option name="LOG_ENABLED" value="false" />
+ <option name="LOG_EXPRESSION_ENABLED" value="false" />
+ <option name="SUSPEND_POLICY" value="SuspendAll" />
+ <option name="COUNT_FILTER_ENABLED" value="false" />
+ <option name="COUNT_FILTER" value="0" />
+ <option name="CONDITION_ENABLED" value="false" />
+ <option name="CLASS_FILTERS_ENABLED" value="false" />
+ <option name="INSTANCE_FILTERS_ENABLED" value="false" />
+ <option name="CONDITION" value="" />
+ <option name="LOG_MESSAGE" value="" />
+ </breakpoint>
+ </line_breakpoints>
<breakpoint_any>
<breakpoint>
<option name="NOTIFY_CAUGHT" value="true" />
@@ -58,10 +73,19 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="itertools.java" pinned="false" current="true" current-in-tab="true">
+ <file leaf-file-name="itertools.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/org/python/modules/itertools.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="707" column="4" selection-start="26609" selection-end="26609" vertical-scroll-proportion="0.8543689">
+ <state line="707" column="4" selection-start="26609" selection-end="26609" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="PyLock.java" pinned="false" current="true" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/src/org/python/modules/thread/PyLock.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -83,6 +107,7 @@
<option name="changedFiles">
<list>
<option value="$PROJECT_DIR$/src/org/python/modules/itertools.java" />
+ <option value="$PROJECT_DIR$/src/org/python/modules/thread/PyLock.java" />
</list>
</option>
</component>
@@ -199,13 +224,40 @@
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
+ <PATH>
+ <PATH_ELEMENT USER_OBJECT="Root">
+ <option name="myItemId" value="" />
+ <option name="myItemType" value="" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT USER_OBJECT="jython27">
+ <option name="myItemId" value="" />
+ <option name="myItemType" value="" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT USER_OBJECT="src">
+ <option name="myItemId" value="" />
+ <option name="myItemType" value="" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT USER_OBJECT="org/python">
+ <option name="myItemId" value="" />
+ <option name="myItemType" value="" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT USER_OBJECT="modules">
+ <option name="myItemId" value="" />
+ <option name="myItemType" value="" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT USER_OBJECT="thread">
+ <option name="myItemId" value="" />
+ <option name="myItemType" value="" />
+ </PATH_ELEMENT>
+ </PATH>
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="GoToFile.includeJavaFiles" value="false" />
- <property name="project.structure.last.edited" value="Project" />
+ <property name="project.structure.last.edited" value="Libraries" />
+ <property name="OverrideImplement.combined" value="true" />
<property name="project.structure.proportion" value="0.0" />
<property name="options.splitter.main.proportions" value="0.3" />
<property name="MemberChooser.sorted" value="false" />
@@ -343,6 +395,24 @@
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
+ <component name="SvnConfiguration" maxAnnotateRevisions="500">
+ <option name="USER" value="" />
+ <option name="PASSWORD" value="" />
+ <option name="mySSHConnectionTimeout" value="30000" />
+ <option name="mySSHReadTimeout" value="30000" />
+ <option name="LAST_MERGED_REVISION" />
+ <option name="MERGE_DRY_RUN" value="false" />
+ <option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
+ <option name="UPDATE_LOCK_ON_DEMAND" value="false" />
+ <option name="IGNORE_SPACES_IN_MERGE" value="false" />
+ <option name="DETECT_NESTED_COPIES" value="true" />
+ <option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
+ <option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
+ <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
+ <option name="FORCE_UPDATE" value="false" />
+ <configuration useDefault="true">$USER_HOME$/.subversion_IDEA</configuration>
+ <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
+ </component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="bce1b1d0-380f-4885-b052-d71e69b3b8fa" name="Default" comment="" />
@@ -429,11 +499,106 @@
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/org/python/modules/itertools.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="707" column="4" selection-start="26609" selection-end="26609" vertical-scroll-proportion="0.8543689">
+ <state line="707" column="4" selection-start="26609" selection-end="26609" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/src/org/python/modules/thread/PyLock.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</component>
+ <component name="masterDetails">
+ <states>
+ <state key="ArtifactsStructureConfigurable.UI">
+ <settings>
+ <artifact-editor />
+ <splitter-proportions>
+ <option name="proportions">
+ <list>
+ <option value="0.2" />
+ </list>
+ </option>
+ </splitter-proportions>
+ </settings>
+ </state>
+ <state key="FacetStructureConfigurable.UI">
+ <settings>
+ <last-edited>No facets are configured</last-edited>
+ <splitter-proportions>
+ <option name="proportions">
+ <list>
+ <option value="0.2" />
+ </list>
+ </option>
+ </splitter-proportions>
+ </settings>
+ </state>
+ <state key="GlobalLibrariesConfigurable.UI">
+ <settings>
+ <splitter-proportions>
+ <option name="proportions">
+ <list>
+ <option value="0.2" />
+ </list>
+ </option>
+ </splitter-proportions>
+ </settings>
+ </state>
+ <state key="JdkListConfigurable.UI">
+ <settings>
+ <last-edited>1.7</last-edited>
+ <splitter-proportions>
+ <option name="proportions">
+ <list>
+ <option value="0.2" />
+ </list>
+ </option>
+ </splitter-proportions>
+ </settings>
+ </state>
+ <state key="ModuleStructureConfigurable.UI">
+ <settings>
+ <last-edited>Jython27</last-edited>
+ <splitter-proportions>
+ <option name="proportions">
+ <list>
+ <option value="0.2" />
+ <option value="0.5" />
+ </list>
+ </option>
+ </splitter-proportions>
+ </settings>
+ </state>
+ <state key="ProjectJDKs.UI">
+ <settings>
+ <last-edited>1.7</last-edited>
+ <splitter-proportions>
+ <option name="proportions">
+ <list>
+ <option value="0.20000002" />
+ </list>
+ </option>
+ </splitter-proportions>
+ </settings>
+ </state>
+ <state key="ProjectLibrariesConfigurable.UI">
+ <settings>
+ <last-edited>extlibs</last-edited>
+ <splitter-proportions>
+ <option name="proportions">
+ <list>
+ <option value="0.2" />
+ </list>
+ </option>
+ </splitter-proportions>
+ </settings>
+ </state>
+ </states>
+ </component>
</project>
diff --git a/src/org/python/modules/thread/PyLock.java b/src/org/python/modules/thread/PyLock.java
--- a/src/org/python/modules/thread/PyLock.java
+++ b/src/org/python/modules/thread/PyLock.java
@@ -1,10 +1,9 @@
// Copyright (c) Corporation for National Research Initiatives
package org.python.modules.thread;
-import org.python.core.Py;
-import org.python.core.PyObject;
+import org.python.core.*;
-public class PyLock extends PyObject {
+public class PyLock extends PyObject implements ContextManager {
private boolean locked = false;
@@ -45,4 +44,16 @@
public boolean locked() {
return locked;
}
+
+ @Override
+ public PyObject __enter__(ThreadState ts) {
+ acquire();
+ return this;
+ }
+
+ @Override
+ public boolean __exit__(ThreadState ts, PyException exception) {
+ release();
+ return false;
+ }
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list