【问题标题】:Python poster buffer sizePython海报缓冲区大小
【发布时间】:2013-07-12 10:14:41
【问题描述】:

我正在使用Python poster module 0.8.1,我想知道是否可以增加默认上传缓冲区大小或“块大小”?我发现默认缓冲区大小为 4096 字节(http://atlee.ca/software/poster/poster.encode.html#poster.encode.MultipartParam.iter_encode) 我试图在文档中搜索一些提示,但没有运气。

【问题讨论】:

    标签: python file-upload poster


    【解决方案1】:

    API 没有给你设置块大小的机会,没有。

    您可以通过修补函数上的常量来增加缓冲区:

    from poster.encode import MultipartParam
    
    iter_encode = MultipartParam.iter_encode.im_func  # function object
    iter_encode.func_defaults = (8192,)  # set new defaults, a 1-element tuple
    

    函数的.func_defaults参数可以随意替换,只要保证替换成等长的元组即可。

    【讨论】:

    • 非常感谢,这正是我所需要的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 2014-06-10
    • 1970-01-01
    • 1970-01-01
    • 2011-11-26
    • 2021-09-18
    • 2012-04-11
    相关资源
    最近更新 更多