This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author graham.coster
Recipients Gary Fernie, James Hennessy, graham.coster, martin.panter, methane, nubirstein, r.david.murray, serhiy.storchaka, terry.reedy
Date 2019-10-28.23:46:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572306406.72.0.0542092082155.issue38625@roundup.psfhosted.org>
In-reply-to
Content
Hi there,

As demonstrated in the attached script, I found that a StopIteration exception occurs once a SpooledTemporaryFile has been rolled over from memory to disk, even though seek(0) had move the file position to the top of the file.

I had previously been using a TemporaryFile, which wrote directly to disk, without any issues.  However, once I swapped to a SpooledTemporaryFile, the StopIteration exception started to appear.  

I'm guessing the problem relates to the csv reader having an Iterator that is no longer looking at the correct file after the SpooledTemporaryFile is rolled-over.  I found that instantiating a new csv reader post roll-over works around the problem.

I had expected that I could just swap from a TemporaryFile to a SpooledTemporaryFile with no change to behaviour. However, if this is not the case, perhaps the SpooledTemporaryFile documentation should explicitly state this.

Cheers, Graham.
History
Date User Action Args
2019-10-28 23:46:46graham.costersetrecipients: + graham.coster, terry.reedy, r.david.murray, methane, martin.panter, serhiy.storchaka, Gary Fernie, James Hennessy, nubirstein
2019-10-28 23:46:46graham.costersetmessageid: <1572306406.72.0.0542092082155.issue38625@roundup.psfhosted.org>
2019-10-28 23:46:46graham.costerlinkissue38625 messages
2019-10-28 23:46:46graham.costercreate