sandbox/utils.py
def container_ram_swap() -> Tuple[int, int]:
    """Return ram and swap available to a container.
    
    See https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
    for mere details.
    """
    ram = settings.DOCKER_PARAMETERS.get("mem_limit", -1)
    if ram == "-1":
        ram = -1
    if ram != -1:
        ram = humanfriendly.parse_size(ram)
    
    swap = settings.DOCKER_PARAMETERS.get("memswap_limit", 0)
    if swap == "-1":
        swap = -1
    if swap != -1:
        swap = humanfriendly.parse_size(swap)
    
    if ram == -1 and swap == -1:
        return -1, -1
    if ram == swap:
        return ram, 0
    if ram >= 0 and swap == 0:
        return ram, ram
    
    return ram, swap - ram
Return ram and swap available to a container.
    
    See https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
    for mere details.
    
Return ram and swap available to a container.
Return ram and swap available to a container .
def container_ram_swap() -> Tuple[int, int]:
    ram = settings.DOCKER_PARAMETERS.get("mem_limit", -1)
    if ram == "-1":
        ram = -1
    if ram != -1:
        ram = humanfriendly.parse_size(ram)
    swap = settings.DOCKER_PARAMETERS.get("memswap_limit", 0)
    if swap == "-1":
        swap = -1
    if swap != -1:
        swap = humanfriendly.parse_size(swap)
    if ram == -1 and swap == -1:
        return -1, -1
    if ram == swap:
        return ram, 0
    if ram >= 0 and swap == 0:
        return ram, ram
    return ram, swap - ram
def container_ram_swap ( ) -> Tuple [ int , int ] : ram = settings . DOCKER_PARAMETERS . get ( "mem_limit" , - 1 ) if ram == "-1" : ram = - 1 if ram != - 1 : ram = humanfriendly . parse_size ( ram ) swap = settings . DOCKER_PARAMETERS . get ( "memswap_limit" , 0 ) if swap == "-1" : swap = - 1 if swap != - 1 : swap = humanfriendly . parse_size ( swap ) if ram == - 1 and swap == - 1 : return - 1 , - 1 if ram == swap : return ram , 0 if ram >= 0 and swap == 0 : return ram , ram return ram , swap - ram
Return ram and swap available to a container.
Return ram and swap available to a container .
"""Return ram and swap available to a container.
    
    See https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
    for mere details.
    """