From: Sébastien D. <se...@de...> - 2011-05-10 09:40:20
|
Hi Guys, I am currently building a forge that propose Wiki functionnality persisted in DVCS (GIT, Mercurial) and use RestructuredText as main wiki language. In order to acheive this, we have bundled docutils within jython-2.5.2.jar, and called it from our Java code. It works fine, even if startup type before the first call seems to me quite long (10 seconds). The main issue is that it works when we run the rst2html the first time, but next calls return empty content. I suspect that JarRunner, originally made to be called from a unique main method, is the root of our issue. Our code is the following, and run the __run__.py built from rst2html.py : public String generate(File source) throws IOException { String[] commandLine= new String[5]; commandLine[0] = source.getAbsolutePath(); commandLine[1] = "--stylesheet"; commandLine[2] = css.getAbsolutePath(); commandLine[3] = "--template"; commandLine[4] = template.getAbsolutePath(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); System.setOut(ps); JarRunner.run(commandLine); ps.flush(); baos.flush(); return baos.toString(); } What I plan to do, but not really know how : - Intialize Python state one time, at the creation of my Rst2Html.jar class - Use directly PythonInterpreter to run the content of rst2html.py Does anybody has already used Jython in such server context to run command line multiple times ? How could I run PythonInterpreter to run rst2html.py ? I sthere a more appropriate way to do this ? Thanks in advance, Sébastien |
From: Pierre T. <pie...@gm...> - 2011-05-10 16:12:49
|
Hello, I think it would be far better to use a Jython object on the Java side implementing the interface you need. Look here: http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications 2011/5/10 Sébastien Deleuze <se...@de...> > Hi Guys, > > I am currently building a forge that propose Wiki functionnality > persisted in DVCS (GIT, Mercurial) and use RestructuredText as main > wiki language. > In order to acheive this, we have bundled docutils within > jython-2.5.2.jar, and called it from our Java code. > It works fine, even if startup type before the first call seems to me > quite long (10 seconds). > > The main issue is that it works when we run the rst2html the first > time, but next calls return empty content. > I suspect that JarRunner, originally made to be called from a unique > main method, is the root of our issue. > > Our code is the following, and run the __run__.py built from rst2html.py : > > public String generate(File source) throws IOException { > String[] commandLine= new String[5]; > commandLine[0] = source.getAbsolutePath(); > commandLine[1] = "--stylesheet"; > commandLine[2] = css.getAbsolutePath(); > commandLine[3] = "--template"; > commandLine[4] = template.getAbsolutePath(); > > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > PrintStream ps = new PrintStream(baos); > System.setOut(ps); > > JarRunner.run(commandLine); > ps.flush(); > baos.flush(); > > return baos.toString(); > } > > What I plan to do, but not really know how : > - Intialize Python state one time, at the creation of my Rst2Html.jar > class > - Use directly PythonInterpreter to run the content of rst2html.py > > Does anybody has already used Jython in such server context to run > command line multiple times ? > How could I run PythonInterpreter to run rst2html.py ? I sthere a > more appropriate way to do this ? > > Thanks in advance, > Sébastien > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > -- A+ ------------- Pierre My blog and profile (http://pierrethibault.posterous.com)<http://pierrethibault.posterous.com> YouTube page (http://www.youtube.com/user/tubetib)<http://www.youtube.com/user/tubetib> Twitter (http://twitter.com/pierreth2) <http://twitter.com/pierreth2> |
From: Sébastien D. <se...@de...> - 2011-05-10 21:47:11
|
Thanks, I succeed in making it works with direct API calls and PyObject retreiving of the output. My last issue is the 10 seconds Jython startup time. If someone has a tip to make it work faster the first launch, don't hesitate to share it ;) I have tried "jython -m compileall ." before making the JAR but I have no significant startup time difference. I have tried to remove .py and let only generated class in the JAR, to be sure only precompiled classes are used, but it brokes Jython. Regards, Sébastien On Tue, May 10, 2011 at 6:12 PM, Pierre Thibault <pie...@gm...> wrote: > Hello, > > I think it would be far better to use a Jython object on the Java side > implementing the interface you need. > > Look here: > http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications > > 2011/5/10 Sébastien Deleuze <se...@de...> >> >> Hi Guys, >> >> I am currently building a forge that propose Wiki functionnality >> persisted in DVCS (GIT, Mercurial) and use RestructuredText as main >> wiki language. >> In order to acheive this, we have bundled docutils within >> jython-2.5.2.jar, and called it from our Java code. >> It works fine, even if startup type before the first call seems to me >> quite long (10 seconds). >> >> The main issue is that it works when we run the rst2html the first >> time, but next calls return empty content. >> I suspect that JarRunner, originally made to be called from a unique >> main method, is the root of our issue. >> >> Our code is the following, and run the __run__.py built from rst2html.py : >> >> public String generate(File source) throws IOException { >> String[] commandLine= new String[5]; >> commandLine[0] = source.getAbsolutePath(); >> commandLine[1] = "--stylesheet"; >> commandLine[2] = css.getAbsolutePath(); >> commandLine[3] = "--template"; >> commandLine[4] = template.getAbsolutePath(); >> >> ByteArrayOutputStream baos = new ByteArrayOutputStream(); >> PrintStream ps = new PrintStream(baos); >> System.setOut(ps); >> >> JarRunner.run(commandLine); >> ps.flush(); >> baos.flush(); >> >> return baos.toString(); >> } >> >> What I plan to do, but not really know how : >> - Intialize Python state one time, at the creation of my Rst2Html.jar >> class >> - Use directly PythonInterpreter to run the content of rst2html.py >> >> Does anybody has already used Jython in such server context to run >> command line multiple times ? >> How could I run PythonInterpreter to run rst2html.py ? I sthere a >> more appropriate way to do this ? >> >> Thanks in advance, >> Sébastien >> >> >> ------------------------------------------------------------------------------ >> Achieve unprecedented app performance and reliability >> What every C/C++ and Fortran developer should know. >> Learn how Intel has extended the reach of its next-generation tools >> to help boost performance applications - inlcuding clusters. >> http://p.sf.net/sfu/intel-dev2devmay >> _______________________________________________ >> Jython-users mailing list >> Jyt...@li... >> https://lists.sourceforge.net/lists/listinfo/jython-users > > > > -- > > > A+ > > ------------- > Pierre > My blog and profile (http://pierrethibault.posterous.com) > YouTube page (http://www.youtube.com/user/tubetib) > Twitter (http://twitter.com/pierreth2) > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |
From: Pierre T. <pie...@gm...> - 2011-05-10 21:56:46
|
2011/5/10 Sébastien Deleuze <se...@de...> > Thanks, I succeed in making it works with direct API calls and > PyObject retreiving of the output. > > My last issue is the 10 seconds Jython startup time. > If someone has a tip to make it work faster the first launch, don't > hesitate to share it ;) > > Regards, > Sébastien > -- > It seems to be a common problem to all languages running on the JVM. Groovy takes a long time to start too. No language is perfect I guess. A+ ------------- Pierre My blog and profile (http://pierrethibault.posterous.com)<http://pierrethibault.posterous.com> YouTube page (http://www.youtube.com/user/tubetib)<http://www.youtube.com/user/tubetib> Twitter (http://twitter.com/pierreth2) <http://twitter.com/pierreth2> |
From: Alex G. <ale...@ne...> - 2011-05-10 22:14:24
|
11.05.2011 00:56, Pierre Thibault kirjoitti: > 2011/5/10 Sébastien Deleuze <se...@de... <mailto:se...@de...>> > > Thanks, I succeed in making it works with direct API calls and > PyObject retreiving of the output. > > My last issue is the 10 seconds Jython startup time. > If someone has a tip to make it work faster the first launch, don't > hesitate to share it ;) > > Regards, > Sébastien > -- > > > It seems to be a common problem to all languages running on the JVM. > Groovy takes a long time to start too. No language is perfect I guess. > Plain Java starts virtually instantly though, so this problem is not something inherent to the JVM. > A+ > > ------------- > Pierre > My blog and profile (http://pierrethibault.posterous.com) > <http://pierrethibault.posterous.com> > YouTube page (http://www.youtube.com/user/tubetib) > <http://www.youtube.com/user/tubetib> > Twitter (http://twitter.com/pierreth2) <http://twitter.com/pierreth2> > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |
From: Sébastien D. <se...@de...> - 2011-05-10 22:50:33
|
When I activate verbose messages on my jython JAR with precompiled py classes, I see a LOT of messages like this : import: trying _locale$py.class in parent class loader import: trying _locale.py in parent class loader import: trying source D:\Workspaces\kazan\kazan\kazan-wiki\kazan-wiki-rst\__pyclasspath__\_locale import: trying precompiled with no source D:\Workspaces\kazan\kazan\kazan-wiki\kazan-wiki-rst\__pyclasspath__\_locale$py.class If Jython make 4 tries, including parent loader (I don't care, in 99% of uses cases all is in the same JAR = the same classloader), I think it may take a lot of time. Can't I customize classloading strategy to remove this parent first behaviour (even if it is default behaviour for non webapp classloaders) ? Same question about locale$py.class versus locale. On current classloader, it seems to try .py files before precompiled file. Can't I give a parameter to Jython to say him I don't care *.py files since all my py files are already precompiled ? 2011/5/11 Alex Grönholm <ale...@ne...>: > 11.05.2011 00:56, Pierre Thibault kirjoitti: > > 2011/5/10 Sébastien Deleuze <se...@de...> >> >> Thanks, I succeed in making it works with direct API calls and >> PyObject retreiving of the output. >> >> My last issue is the 10 seconds Jython startup time. >> If someone has a tip to make it work faster the first launch, don't >> hesitate to share it ;) >> >> Regards, >> Sébastien >> -- > > It seems to be a common problem to all languages running on the JVM. Groovy > takes a long time to start too. No language is perfect I guess. > > Plain Java starts virtually instantly though, so this problem is not > something inherent to the JVM. > > A+ > > ------------- > Pierre > My blog and profile (http://pierrethibault.posterous.com) > YouTube page (http://www.youtube.com/user/tubetib) > Twitter (http://twitter.com/pierreth2) > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |
From: Pierre T. <pie...@gm...> - 2011-05-10 23:08:07
|
2011/5/10 Sébastien Deleuze <se...@de...> > > If Jython make 4 tries, including parent loader (I don't care, in 99% > of uses cases all is in the same JAR = the same classloader), I think > it may take a lot of time. > > May be not because it is time spent at locating files while, I believe, loading the real file is taking much more time. I guess JVM languages are having a lot of initialization code. -- A+ ------------- Pierre My blog and profile (http://pierrethibault.posterous.com)<http://pierrethibault.posterous.com> YouTube page (http://www.youtube.com/user/tubetib)<http://www.youtube.com/user/tubetib> Twitter (http://twitter.com/pierreth2) <http://twitter.com/pierreth2> |