通过流下载 azure blob - 出口 137

2024-01-02

我正在尝试通过 Azure-python-sdk get_blob_to_stream 下载大文件,但是,我的程序不断退出,返回代码为 137 - 这似乎与内存不足有关。 (我可以在顶部看到 python 正在消耗越来越多的内存,直到它被杀死)。

Code:

with io.open(file_path, 'w') as file:
    self.blob_service.get_blob_to_stream(container_name='container', blob_name=blob_name, stream=file)

我在用适用于 python 的 azure sdk https://github.com/Azure/azure-sdk-for-python and 获取blob_to_stream http://azure.github.io/azure-storage-python/ref/azure.storage.blob.baseblobservice.html为此,文件大小约为 6.5 GB。

该文件被创建为 0 字节,并且没有写入任何内容 - 我在这里做了明显错误的事情吗?


下载 SDK 并浏览代码后,我找到了如何下载这个大块。

  1. You must提供大于 1 的 max_connections 值 - 这使得能够以块的形式下载文件并将其写入流。
  2. 您需要传入二进制流('wb')

问题示例中的工作代码:

with io.open(file_path, 'wb') as file:
    self.blob_service.get_blob_to_stream(container_name='wxdata', blob_name=blob_name, stream=file, max_connections=2)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过流下载 azure blob - 出口 137 的相关文章

随机推荐