问题
When running Jython programs through nailgun the jython program always runs with the command line arguments of the first time it was run.
first I start nailgun:
arthur@a:~/nailgun$ java -jar nailgun.jar
NGServer started on all interfaces, port 2113.
then when I run a simple jython script:
import sys
print sys.argv
then add jython to nailguns classpath
./ng ng-cp /usr/share/java/jython.jar
then run the script with the word "first" as an arguemnt:
arthur@a:~/nailgun$ ./ng org.python.util.jython tmp.jy first
*sys-package-mgr*: can't create package cache dir, '/usr/share/java/jython.jar/cachedir/packages'
['tmp.jy', 'first']
run it again with the word "second" as an argument, and it prints "first"
arthur@a:~/nailgun$ ./ng org.python.util.jython tmp.jy second
['tmp.jy', 'first']
and always prints "first" from then on:
arthur@a:~/nailgun$ ./ng org.python.util.jython tmp.jy third
['tmp.jy', 'first']
回答1:
nailgun author here.
Nailgun doesn't cache command line arguments by design, but singletons and other static variables will survive between invocations.
I'm not a python guy, but the "sys.argv" usage sure looks like a singleton to me. I'd suggest looking into jython's command line argument handling to see why it's not getting updated.
If you do this please post what you find... it might be something in nailgun but it's not something I've ever seen in several years of use.
来源:https://stackoverflow.com/questions/6350976/why-does-nailgun-cache-command-line-arguments