Skip to content

Instantly share code, notes, and snippets.

@darjus
Created March 8, 2017 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darjus/52f1500f5a0b70b5e34eb60bf6a03340 to your computer and use it in GitHub Desktop.
Save darjus/52f1500f5a0b70b5e34eb60bf6a03340 to your computer and use it in GitHub Desktop.
➜ jython hg diff
diff --git a/src/org/python/core/Deriveds.java b/src/org/python/core/Deriveds.java
--- a/src/org/python/core/Deriveds.java
+++ b/src/org/python/core/Deriveds.java
@@ -48,7 +48,7 @@
PyObject getattribute = type.lookup("__getattribute__");
// This is a horrible hack for eventual consistency of the cache. We hope that the cached version
// becomes available, but don't wait forever.
- for (int i = 0; i < 100000; i++) {
+ for (int i = 0; i < 100000000; i++) {
if (getattribute != null) {
break;
}
diff --git a/src/org/python/core/PyType.java b/src/org/python/core/PyType.java
--- a/src/org/python/core/PyType.java
+++ b/src/org/python/core/PyType.java
@@ -1539,13 +1539,16 @@
return fromClass(c, true);
}
+ /**
+ * This method is not thread safe at the moment and requires hackery in
+ * @see org.python.core.Deriveds#__findattr_ex__() for example, to be used safely in multithreaded
+ * environmnet.
+ *
+ **/
public static PyType fromClass(Class<?> c, boolean hardRef) {
PyType type = getClassToType().get(c);
if (type != null) {
- // synchronize on the c here to make sure the compiler does not re-order
- synchronized (c) {
- return type;
- }
+ return type;
}
// We haven't seen this class before, so its type needs to be created. If it's being
// exposed as a Java class, defer processing its inner types until it's completely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment