无缓冲的 urllib2.urlopen [英] unbuffered urllib2.urlopen

查看:36
本文介绍了无缓冲的 urllib2.urlopen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于 Web 界面的客户端,用于长时间运行的进程.我希望该过程的输出显示出来.与 urllib.urlopen() 配合使用效果很好,但它没有 timeout 参数.另一方面,使用 urllib2.urlopen() 输出被缓冲.有没有简单的方法可以禁用该缓冲区?

I have client for web interface to long running process. I'd like to have output from that process to be displayed as it comes. Works great with urllib.urlopen(), but it doesn't have timeout parameter. On the other hand with urllib2.urlopen() the output is buffered. Is there a easy way to disable that buffer?

推荐答案

我想到的一个快速技巧是使用 urllib.urlopen()threading.Timer() 模拟超时.但这只是快速而肮脏的黑客攻击.

A quick hack that has occurred to me is to use urllib.urlopen() with threading.Timer() to emulate timeout. But that's only quick and dirty hack.

这篇关于无缓冲的 urllib2.urlopen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆