On 22/12/2012 23:21, Philip Jenvey wrote:
> On Dec 22, 2012, at 7:09 AM, Jeff Allen wrote:
>> I've adapted the Closer object Philip provided in _io.fileio to apply to I/O objects in general. As before, it engages the general mechanism register/unregisterCloser() in PySystemState. The container that holds the closers, although it is a set, guarantees iteration in the order objects were added.
>> The reverse order is what guarantees (in most circumstances) flushing the buffers before force-closing the file into which they should go. And the copy would fix the concurrent modification error that occurs when the downstream file tries to remove itself during flush-and-close propagation.
>> Does anyone see a problem with messing with the order in this way?
> I don't think reversing the order or cloning the closers would matter, anyway.
>> There can be multiple PySystemState objects. Should I think of these as distinct interpreters, or is there some chance a Python object from one of them would be in use in another at the time clean up occurs? Do PySystemState objects always hang around until JVM exit or might they clean up sooner?
> I'm pretty sure you can assume that (as distinct/per interpreter)
Thanks for all that. I've now made this change in
http://hg.python.org/jython/rev/68c3d85a3a6b . In the unit test I tried
several combinations of new PySystemState and new PythonInterpreter
before each test case, without getting the test to run cleanly. Objects
from an earlier test would still be lying around. With a new
PySystemState I had two distinct PyType objects representing <class
'codecs.CodecInfo'>, which meant that my codec was apparently not a
codec. But re-sing PySystemState fails because once cleanup() is called,
it accepts no more closer registrations. I've made a slightly dubious
change to PySystemState to permit re-use after clean up completes.
I suspect here is something fundamental wrong here, but I find it
difficult to guess what. I notice in a recent comment to issue #1327
Frank intends changes in the same area. Maybe it will come with an