Why is Current Dropbox Python API Delayed 100 Seconds When Listing Files? - Stack Overflow

admin2025-04-19  1

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)
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745021431a280405.html

最新回复(0)