I ran into the error:
"LookupError: no codec search functions registered: can't find encoding"
using jython 2.1 on windows and with little debugging, I found that
the problem exists with latest trunk as well. The following code
demonstrates the issue:
-------------
import java
import time
class codec_test(java.lang.Runnable):
def run(self):
print "test string".encode('utf-8')
th1 = java.lang.Thread(codec_test())
th2 = java.lang.Thread(codec_test())
th1.start()
# time.sleep(1)
th2.start()
-------------
My tests are on SuSe 10 using "Jython 2.2 on java1.6.0_02". When run
as is, I consistently get the following result:
-------------
Exception in thread "Thread-1" Traceback (innermost last):
File "codec_test.py", line 15, in run
LookupError: no codec search functions registered: can't find encoding
test string
-------------
If "time.sleep(1)" line is uncommented, the result is:
-------------
test string
test string
-------------
The problem is in codecs.java's lookup() and registry_init(). When two
threads call lookup() simultaneously, one thread's registry_init()
returns even when it is not done importing all the codecs. What does
one think of synchronizing the method "registry_init()"? The above
test consistently passes with that change.
Thanks,
Raghu
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev