Skip to content

glaes.core.util

glaes.core.util

checkMultiProcessingAvailability

checkMultiProcessingAvailability(multiProcess: bool) -> bool

Multiprocessing is not available on all operating systems. If the user wants to to use multiprocessing on an unsupported operating system, multiprocessing will be deactivated and a warning appears.

Parameters:

Name Type Description Default
multiProcess bool

A flag indicating whether multiprocessing should be used as indicated by the user. If multiprocessing is not available for the operating system, multiprocessing will be deactivated and a warning appears.

required

Returns:

Type Description
bool

The corrected value for multiprocessing availability.

Source code in glaes/core/util.py
def checkMultiProcessingAvailability(multiProcess: bool) -> bool:
    """Multiprocessing is not available on all operating systems. If the user wants to
    to use multiprocessing on an unsupported operating system, multiprocessing will be
    deactivated and a warning appears.

    Parameters
    ----------
    multiProcess : bool
        A flag indicating whether multiprocessing should be used as indicated by the user.
        If multiprocessing is not available for the operating system, multiprocessing will be deactivated and a warning appears.

    Returns
    -------
    bool
        The corrected value for multiprocessing availability.
    """
    if platform == "linux" or platform == "linux2":
        multiProcessCorrected = multiProcess
    elif platform == "darwin" and multiProcess is True:
        multiProcessCorrected = False
        warn(message=GeokitMultiProcessingWarning.multiProcessingWarningMessage, category=GeokitMultiProcessingWarning)
    elif platform == "win32" and multiProcess is True:
        multiProcessCorrected = False
        warn(message=GeokitMultiProcessingWarning.multiProcessingWarningMessage, category=GeokitMultiProcessingWarning)
    elif multiProcess is False:
        multiProcessCorrected = multiProcess
    else:
        multiProcessCorrected = False
        warn(message=GeokitMultiProcessingWarning.multiProcessingWarningMessage, category=GeokitMultiProcessingWarning)
    return multiProcessCorrected