Reputation: 331280
I have an application that allows you to use a Python startup script. I want to run one part of the code after the application is fully initialized, but there is no way to know this.
I used time.sleep()
but then the application hangs till it executes that code. I also transferred the code to another file and used execfile
but same result.
So basically I want something like this:
startup script:
my code
code to run 5 seconds later
What's the easiest way to achieve this? Do I have to use threading for this?
Upvotes: 2
Views: 540
Reputation: 2419
How about at the end of your startup script
it writes to or creates a log file contains something like 'initiation complete'
.
So another code will check if the file is created or the text is written after each x millisecond and then execute the rest of it.
Upvotes: 1