Yes recursion is not supported. We had already a ticket on this specific aspect of your issue:

  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      Deadlock on recursive tf.function-decorated function 2
    

    
      
        opened 
        
          
        
        Jan 2, 2020
      
      


      
        
          
          jonas-eschle
        
      
    

    
        type:bug
        comp:core
        TF 2.2
    
  


  
    **System information**
- Have I written custom code (as opposed to using a stoc…k example script provided in TensorFlow): yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 19.10
- TensorFlow installed from (source or binary): binary, conda
- TensorFlow version (use command below): unknown 2.0.0
- Python version: 3.7

**Describe the current behavior**

Recursive calls with a `tf.function` decorated python function results in a deadlock. A minimal example is provided below.

Where it gets stuck: by recursively calling `_maybe_define_function`, which internally requires a lock (line 2118 in `tensorflow_core/python/eager.function.py`). This seems to deadlock when trying to create a graph function again invoking itself.

About use-cases: yes, there are. But yes, in principle, there are "workarounds". But I assume this is not in general intended to produce a deadlock anyway, should it? If so, I would rather propose a loud failure.

**Code to reproduce the issue**
```
@tf.function(autograph=False)
def func1(depth=0):
    if depth > 1:
        return depth
    else:
        return func1(depth + 1)

func1(0)
```