Ref : https://github.com/python/cpython/pull/25174

https://github.com/localstack/localstack/blob/5a5edcd9d9ccbd6a56f23d71e3a1131b8c814996/localstack/utils/common.py#L324
""" Dummy class that can be used for mocking custom attributes. """
    pass
class CustomEncoder(json.JSONEncoder):
    """ Helper class to convert JSON documents with datetime, decimals, or bytes. """
    def default(self, o):
        import yaml  
        if isinstance(o, decimal.Decimal):
            if o % 1 > 0:
                return float(o)
            else:
                return int(o)
        if isinstance(o, (datetime, date)):
            return timestamp_millis(o)
        if isinstance(o, yaml.ScalarNode):
            if o.tag == 'tag:yaml.org,2002:int':
                return int(o.value)
            if o.tag == 'tag:yaml.org,2002:float':
                return float(o.value)
            if o.tag == 'tag:yaml.org,2002:bool':
                return bool(o.value)
            return str(o.value)
        try:
            if isinstance(o, six.binary_type):
                return to_str(o)
            return super(CustomEncoder, self).default(o)
        except Exception:
            return None
class ShellCommandThread(FuncThread):