In My Python Script I was determining directory size in Azure Datalake storage Gen2. And the code works fine until I check for a bigger directory.
import sys
from dbutils import FileInfo
from typing import List
sys.setrecursionlimit(2000)
root_path = "/mnt/datalake/.../"
def discover_size(path: str, verbose: bool = True):
def loop_path(paths: List[FileInfo], accum_size: float):
if not paths:
return accum_size
else:
head, tail = paths[0], paths[1:]
if head.size > 0:
if verbose:
accum_size += head.size / 1e6
return loop_path(tail, accum_size)
else:
extended_tail = dbutils.fs.ls(head.path) + tail
return loop_path(extended_tail, accum_size)
return loop_path(dbutils.fs.ls(path), 0.0)
discover_size(root_path, verbose=True)
First see OOM(Out of Memory) Issue and added
sys.setrecursionlimit(2000)
.
Now, Another error-
RecursionError: maximum recursion depth exceeded in comparison
How to overcome this issue.