Import of main script from stub script causing freezing
Question
I am building an application to distribute with py2app. As I don't want the source to be extracted from the .app file, I have a stub file, named run.py, which then runs the code in mainapp.py:
import mainapp
Running this directly in a terminal (no py2app involvement) gives a freezing in a gevent dependent part of the code. The result is the same when turned into a .app. Does importing in the above manner change any of the interpreter's environment? It seems strange that there is just freezing, no error messages (there is no try/catch block.)
No correct solution
OTHER TIPS
When you import a module in Python, that module is executed. Make sure that in mainapp
there is no "free code" that can freeze your python VM (like infinite loop).
"Free code" is the set of the instructions that are outside function or class definition.
For example in
import one_module
while(true) :
various_code()
def foo() :
print "bar"
the second line is free-code.
When I try to import this script the while
instruction is executed and python freeze.