Message3768

Author cgroves
Recipients cgroves
Date 2008-11-09.18:40:56
SpamBayes Score 1.4597293e-07
Marked as misclassified No
Message-id <1226256057.24.0.232504578776.issue1169@psf.upfronthosting.co.za>
In-reply-to
Content
From
http://www.nabble.com/problem-with-jython-and-threads-to20371245.html#a20371245:

== 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.
History
Date User Action Args
2008-11-09 18:40:57cgrovessetrecipients: + cgroves
2008-11-09 18:40:57cgrovessetmessageid: <1226256057.24.0.232504578776.issue1169@psf.upfronthosting.co.za>
2008-11-09 18:40:57cgroveslinkissue1169 messages
2008-11-09 18:40:56cgrovescreate