【发布时间】:2014-10-11 12:18:45
【问题描述】:
我想异步读取一个大文件,一次 20 行,我们如何使用扭曲框架来做到这一点?
我的代码的 sn-p,但被阻塞:
with open(file_path) as f:
if (importState.status == ImportStateFile.STATUS_AWAY):
f.seek(importState.fileIndex, 0)
while True:
importState.fileIndex = importState.fileIndex + len(''.join(emails))
d1 = get_emails(f)
d1.addCallback(process_emails).addCallback(insert_emails_status)
d1.addErrback(finalize_import)
【问题讨论】:
标签: python asynchronous twisted