To run a python code before start, an easy way is to use Python Snippet block in GNU radio. Select section of Flow graph to After Init or After Start as required. Put the code to Code Snippet
section of Flow graph
After Init
After Start
Code Snippet