|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Cleaning up PythonInterpreter objectHello, Is there a way to "reset" the interpreter, or should I just recreate it?
Best Regards, Joonas ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Cleaning up PythonInterpreter objectIt seems that the only way to really "reset" the interpreter would be to recreate it as you mention. I do agree with you that cleanup() seems that it should do the trick...but instead does nothing notable.
Can we ask what you are doing with the interpreter? Are object factories (http://jythonpodcast.hostjava.net/jythonbook/chapter10.html#object-factories) a solution that may work for you? If so, they are quite easy to use and there is a PySystemState object factory that performs fairly well. This may be something for you to look into. You may also want to take a look at using JSR-223 as it may do the trick for you.
Best Josh Juneau juneau001@... http://jj-blogger.blogspot.com Twitter ID: javajuneau On Fri, Nov 6, 2009 at 6:48 AM, Joonas Pulakka <joonas.pulakka@...> wrote:
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Cleaning up PythonInterpreter objectActually I was working with exactly the object factory section that you mention. However, I think these examples are not quite production-quality code:
* http://jythonpodcast.hostjava.net/jythonbook/chapter10.html#one-to-one-jython-object-factories forces to recreate PythonInterpreter each time a new type of Jython->Java object is needed. The factory can only be reused for building several objects of same type. * http://jythonpodcast.hostjava.net/jythonbook/chapter10.html#making-use-of-a-loosely-coupled-object-factory : The upper listing recreates PythonInterpreter each time a new Jython->Java object is needed - it's doesn't even reuse the interpreter for same types of objects (like the previous example does). The lower one (that uses PySystemState) contains the descriptive comment: "// likely want to reuse PySystemState in some clever fashion since expensive to setup..." So from the doc it seems that nobody has really figured out how to actually implement this reuse thing. Anyway, thanks for pointing out PlyJy in the other mail, I'll have a look at it. Best, Joonas 2009/11/8 Josh Juneau <juneau001@...> It seems that the only way to really "reset" the interpreter would be to recreate it as you mention. I do agree with you that cleanup() seems that it should do the trick...but instead does nothing notable. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Cleaning up PythonInterpreter objectlooping through the script locals and setting them to null seems to work for me
e.g. List<String> scriptLocals = new ArrayList<String>(); PyObject locals = interp.getLocals(); for (PyObject item : locals.__iter__().asIterable()) { scriptLocals.add(item.toString()); } for (String string : scriptLocals) { interp.set(string, null); } this is the simplified version, you would probably need to ignore "__name__" and "__doc__"
|
| Free embeddable forum powered by Nabble | Forum Help |