def _initialize_recursion_depth(self):
        """Ensure recursion info is initialized, if not, initialize it."""
        from furious.context import get_current_async

        recursion_options = self._options.get('_recursion', {})

        current_depth = recursion_options.get('current', 0)
        max_depth = recursion_options.get('max', MAX_DEPTH)

        try:
            executing_async = get_current_async()

            # If this async is within an executing async, use the depth off
            # that async.  Otherwise use the depth set in the async's options.
            current_depth = executing_async.recursion_depth

            # If max_depth does not equal MAX_DEPTH, it is custom. Otherwise
            # use the max_depth from the containing async.
            if max_depth == MAX_DEPTH:
                executing_options = executing_async.get_options().get(
                    '_recursion', {})
                max_depth = executing_options.get('max', max_depth)

        except errors.NotInContextError:
            # This Async is not being constructed inside an executing Async.
            pass

        # Store the recursion info.
        self.update_options(_recursion={'current': current_depth,
                                        'max': max_depth})
def _initialize_recursion_depth ( self ) : from furious . context import get_current_async recursion_options = self . _options . get ( '_recursion' , { } ) current_depth = recursion_options . get ( 'current' , 0 ) max_depth = recursion_options . get ( 'max' , MAX_DEPTH ) try : executing_async = get_current_async ( ) current_depth = executing_async . recursion_depth if max_depth == MAX_DEPTH : executing_options = executing_async . get_options ( ) . get ( '_recursion' , { } ) max_depth = executing_options . get ( 'max' , max_depth ) except errors . NotInContextError : pass self . update_options ( _recursion = { 'current' : current_depth , 'max' : max_depth } )
Ensure recursion info is initialized, if not, initialize it.