admin管理员组文章数量:1410689
I'm using the most recent Dropbox Python API (12.0.2) to list files in a Dropbox Application: dbx.files_list_folder succeeds, but it takes just over 100 seconds for the call to complete. 100 seconds is the amount of time the network timeout seems to be set to within the Python library itself. If I change that value directly in the library code, the response comes back almost immediately.
Notes:
- The delay happens even if there are ZERO files in the directory
- This happens using Python whether from a Mac client or on a VM in the cloud on Linux
- This does not happen when using the Java wrapper
- This is a new phenomenon within the last several months
Has the Python dbx library gone bad? Has something changed on the Dropbox servers?
def list_dropbox_directory( folder_path=""):
try:
# Initialize Dropbox client
dbx = Dropbox("my_token")
# Call to list folder contents
result = dbx.files_list_folder(folder_path,limit=5)
print("Directory listing for folder:", folder_path or "/")
# Process and display file/folder metadata
for entry in result.entries:
try:
entry_type = "File" if isinstance(entry, dropbox.files.FileMetadata) else "Folder"
print(f"{entry_type}: {entry.name} [Path: {entry.path_display}]")
except AttributeError as e:
print(f"Could not display entry {entry}: {e}")
# Keep iterating if there are more files (pagination)
while result.has_more:
result = dbx.files_list_folder_continue(result.cursor)
for entry in result.entries:
try:
entry_type = "File" if isinstance(entry, dropbox.files.FileMetadata) else "Folder"
print(f"{entry_type}: {entry.name} [Path: {entry.path_display}]")
except AttributeError as e:
print(f"Could not display entry {entry}: {e}")
except exceptions.AuthError as auth_err:
print("ERROR: Invalid access token.")
print(auth_err)
except Exception as e:
print("An unexpected error occurred:")
print(e)
本文标签: Why is Current Dropbox Python API Delayed 100 Seconds When Listing FilesStack Overflow
版权声明:本文标题:Why is Current Dropbox Python API Delayed 100 Seconds When Listing Files? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745021429a2638152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论