Josh,

I have a possible fix for this problem, http://bugs.jython.org/file886/threadstate.patch. See http://bugs.jython.org/issue1327 for the discussion, part of an overall discussion on refactoring ThreadState. My solution is necessarily limited, but if it fixes your issue, we can consider applying a version of it to 2.5.2.

- Jim

On Sat, Oct 2, 2010 at 12:27 AM, Jim Baker <jbaker@zyasoft.com> wrote:
Josh,

Looks like a bug in some of the oldest code in the Jython codebase. This specific type error is raised in Py#initProxy, and is related to how we build up a stack of proxies in a LinkedList that are currently being initialized and tracking them through ThreadState (which uses a Java TheadLocal). The reason we need to use a ThreadLocal is the usual one: we have a callpath through arbitrary Java code, but when the thread re-enters Jython, it needs to know its context.

But ThreadState has known problems when interacting with thread pools. See my recent blog post for more on this. This problem is probably why you're seeing this bug here, Scala's actors use a thread pool, and the Scala objects in question may be relying on such actors. (This is speculation, however, I only have a sketchy understanding of Scala.)

In this particular case, there should be no such problem. Bob Lee has a nice blog post on dynamic scoping, specifically on how to support multiple reentrancy. There's no need for any auxiliary storage in the ThreadState, just use the stack itself. I'm not certain why it's not done here, but it is very old code again. Also ThreadLocal#remove did not become available until Java 5.

In general, we're not going to do any ThreadState/PySystemState API refactoring until 2.6, but dynamic scoping changes like this look pretty safe to me, so we should be able to fix it for 2.5.2.

- Jim


On Fri, Oct 1, 2010 at 10:39 PM, Josh Stratton <strattonbrazil@gmail.com> wrote:
I'm having difficulty accessing some scala objects from my python
interpreter.  I have the following code below and it seems to be
throwing a "TypeError: Proxy instance reused" for some reason.  It's a
Qt widget I'm trying to get, if that makes a difference.

*** python code ***

import com.googlecode.sunshine.Sunshine as Sunshine
from com.trolltech.qt.gui import QWidget as QWidget

print('a')

class Panel(QWidget):
 def __init__(self,parent=None):
     """Documentation"""
     super(Panel,self).__init__(self)

print('b')

mainWindow = Sunshine.getMainWindow()
print(mainWindow)
panel = Panel(mainWindow)
print(panel)

mainWindow.setCentralWidget(Panel())

*** output ***

info] /home/stratton/josh_projects/sunshine-client/
[info] a
[info] b
[info] com::googlecode::sunshine::SunshineWindow(0x8f60acf8)
[error] Exception caught after invoking slot
[error] Traceback (most recent call last):
[error]   File "<iostream>", line 15, in <module>
[error]   File "<iostream>", line 9, in __init__
[error] TypeError: Proxy instance reused

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users