|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
problem with jython and threadsHi. Can anyone tell me why the following does not work?
== Begin import org.python.util.PythonInterpreter; public class test { public static void main(String[] args) throws Exception { for (int i = 0; i < 10; i++) { new Thread () { public void run () { String code = "s = \"Hello " + Thread.currentThread().getName() + "\"\nb = unicode(s,\"utf-8\")\nprint b\n"; System.out.println("code:\n"+code); PythonInterpreter interp = new PythonInterpreter(); interp.exec(code); } }.start(); } } } == End I get "LookupError: no codec search functions registered: can't find encoding" for usually all but one of the threads. Sometimes two or three of them work. If I add "import encodings" to the beginning of the script then it works. Any help would be greatly appreciated! |
|
|
Re: problem with jython and threadsOn Thu, Nov 6, 2008 at 2:39 PM, ag356 <gertner@...> wrote:
> > Hi. Can anyone tell me why the following does not work? > > == Begin > > import org.python.util.PythonInterpreter; > > public class test { > > public static void main(String[] args) throws Exception { > for (int i = 0; i < 10; i++) { > new Thread () { > public void run () { > String code = "s = \"Hello " + > Thread.currentThread().getName() + > "\"\nb = unicode(s,\"utf-8\")\nprint b\n"; > System.out.println("code:\n"+code); > PythonInterpreter interp = new PythonInterpreter(); > interp.exec(code); > } > }.start(); > } > } > > } > > == End > > I get "LookupError: no codec search functions registered: can't find > encoding" for usually all but one of the threads. Sometimes two or three of > them work. > > If I add "import encodings" to the beginning of the script then it works. Looks like we're not synchronizing properly when initializing the codec lookup in org.python.core.codecs. I've opened http://bugs.jython.org/issue1169 to track hunting this down. I imagine this is something we'll take care of before releasing 2.5, but I'm not sure how long it will be before someone really takes a look at it. Charlie ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: problem with jython and threadsOn Nov 6, 2008, at 2:39 PM, ag356 wrote: > > Hi. Can anyone tell me why the following does not work? <snip> > I get "LookupError: no codec search functions registered: can't find > encoding" for usually all but one of the threads. Sometimes two or > three of > them work. > > If I add "import encodings" to the beginning of the script then it > works. > > Any help would be greatly appreciated! Is this on Jython 2.2? I can't reproduce this on trunk. -- Philip Jenvey ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: problem with jython and threadsYes, this was with jython 2.2.1. I just tried it with 2.5b0 and it did not have the problem. So this does seem to be fixed in the newer versions. -ag
|
| Free embeddable forum powered by Nabble | Forum Help |