|
From: Jeff A. <re...@bu...> - 2017-05-06 15:00:27
|
New submission from Jeff Allen: A couple of tests in test_io have started failing for me. This is the case since I localised my PC to Chinese, but encoding seems to have nothing to do with the failure. The test opens one file and creates 20 threads that compete to write in it. There is no explicit synchronisation. The test fails if, at the end, the file does not contain exactly one message from each thread. Comments reference: http://bugs.python.org/issue6750 . Obviously, this is asking for trouble ;) If I reduce the number of threads below about 10 it passes, so maybe it only ever passed because something was faster, slower or "stickier" than now, effectively serialising access. The problem arises in CPython because writing releases the GIL in the middle of managing the buffered data. CPython's solution relies on dancing around the moment when the GIL is given up. In the tracker, this appears to be the triumph of pragmatism over purism. The first answer was that it was "not designed to be thread-safe at all". Of course, we don't have a GIL in Jython, hence I'm actually wondering how this test ever passed, and whether we should expect it to. I'm going to insert a skip for now, referring to this issue. I'm seeing this in the trunk repository (alongside the errors that *are* to do with encoding): ====================================================================== FAIL: test_threads_write (__main__.CTextIOWrapperTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Jeff\Documents\Eclipse\jython-trunk\dist\Lib\test\test_io.py", line 2460, in test_threads_write self.assertEqual(content.count("Thread%03d\n" % n), 1) AssertionError: 0 != 1 ====================================================================== FAIL: test_threads_write (__main__.PyTextIOWrapperTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Jeff\Documents\Eclipse\jython-trunk\dist\Lib\test\test_io.py", line 2460, in test_threads_write self.assertEqual(content.count("Thread%03d\n" % n), 1) AssertionError: 0 != 1 ---------------------------------------------------------------------- In my fork, when I've dealt with the encoding problems, I still have these threading failures. ---------- components: Library keywords: test failure causes messages: 11357 nosy: jeff.allen severity: normal status: open title: test_io failure in concurrent access to a buffered file type: behaviour versions: Jython 2.7 _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue2588> _______________________________________ |