Circular / recursive import error occurs when you try to
import a1 from a.py
in the b.py, which is also used in a1 in a.py.
The solution is to import functions directly in the function body, not in the beginning of the module.
If you have a better approach, you are very welcome to suggest it on the SO question.