diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-04-06 23:11:17 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-04-06 23:11:17 (GMT) |
commit | aa63d0d4af3db832b390ac74517af5eb799540e5 (patch) | |
tree | 86818f84f404fef73ee3f56eb0945334b4d52cb8 /Include | |
parent | ee76777846124bb5b7e08feb488d5bab949c76a5 (diff) | |
download | cpython-aa63d0d4af3db832b390ac74517af5eb799540e5.zip cpython-aa63d0d4af3db832b390ac74517af5eb799540e5.tar.gz cpython-aa63d0d4af3db832b390ac74517af5eb799540e5.tar.bz2 |
Make file objects as thread safe as the underlying libc FILE* implementation.
close() will now raise an IOError if any operations on the file object
are currently in progress in other threads.
Most code was written by Antoine Pitrou (pitrou). Additional testing,
documentation and test suite cleanup done by me (gregory.p.smith).
Fixes issue 815646 and 595601 (as well as many other bugs and
references to this problem dating back to the dawn of Python).
Diffstat (limited to 'Include')
-rw-r--r-- | Include/fileobject.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/fileobject.h b/Include/fileobject.h index 75b0f03..56fae81 100644 --- a/Include/fileobject.h +++ b/Include/fileobject.h @@ -25,6 +25,8 @@ typedef struct { int f_skipnextlf; /* Skip next \n */ PyObject *f_encoding; PyObject *weakreflist; /* List of weak references */ + int unlocked_count; /* Num. currently running sections of code + using f_fp with the GIL released. */ } PyFileObject; PyAPI_DATA(PyTypeObject) PyFile_Type; @@ -38,6 +40,8 @@ PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, int (*)(FILE *)); PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); +PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *); +PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *); PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); |