[Python-Dev] Patch 595601

Tim Peters tim.one@comcast.net
Tue, 24 Jun 2003 21:27:05 -0400


[Greg Ewing]
> If that's the only problem, then surely it's just a matter of correct
> GIL usage? I.e. if a thread using a file object releases the GIL, it
> should re-acquire it and check that the FILE * in the file object is
> still valid before using it again.

Greg, read the patch comments -- they've been there a long time.  There
would be no problem if Python didn't release the GIL around potentially
blocking I/O calls.  But the instant you release the GIL, you have no
guarantee that f->f_fp won't change to NULL from one nanosecond to the next.
There isn't a simple solution to this.