From: Tiago J. (Ext_RI) <Tia...@si...> - 2005-10-03 16:14:37
|
Hello... I'm a newbie to this list and i'm searching for some answers very related to this old mail: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > I have a Web server that runs forever as any server. > On the one hand, if I change any Java code (without changing method > signatures), the changes are reloaded automatically. On the other side, if > I do the same in Jython, I have to restart the server. =20 I guess you are talking about jsps here, aren"t you? =20 > On a compiled language I have more interactivity than with a interpreted > one!!!! > > I have made a trick that when I have an URL of the type > http://myserver/reload/module, I execute the code: import module > reload(module) > > > Does anyone know any workaround to get this result automatically? > I"ve tried to dive into the Jython code, but don"t see what I have in order > to change detect changed source files automatically. =20 I don"t know how exactly your jython interpreter is embedded inside your=20 server, but you should be able to simply create a new instance of that server=20 for each request you are processing - then all code is reloaded. if that=20 works, you can put a piece of java around your interpreter-invocation that=20 checkse for changes of the underlying jython files, and create only then a=20 new interpreter instance. =20 Diez =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D In my case, I'm creating a new instance of the interpreter every time I want to execute a script: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D PySystemState.initialize(t, scriptProp, new String[] { "" }); PythonInterpreter interp =3D new PythonInterpreter(); (...) CtOperations opers =3D new CtOperations(context, _tracer, ctInterp, _adaptorList); interp.set("opers", opers); =09 interp.execfile(script); =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Loading the following props from a file =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D python.cachedir=3DZ:/gm/GenMedCommon/cachedir/GenMedBCB python.path=3DZ:/gm/GenMedBCB/testSrc/GenMedBCBService/scripts;Z:/gm/GenM= e dCommon/testSrc/Common/scripts;Z:/gm/jythonLib =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D I have jyhton files of this kind: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Import package Class =3D package.object() Class.doSomething() =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D And when i change something in the module package, it is not visible. The changes aren't applied. Event creating an interpreter on every execution. What can be happening Thanks in advance Tiago Jorge |