Setting timeout when using os.system function
<p>Firstly, I'd like to say I just begin to learn python, And I want to execute maven command inside my python script (see the partial code below)</p>

<pre>os.system("mvn surefire:test")</pre>

<p>But unfortunately, sometimes this command will time out, So I wanna to know how to set a timeout threshold to control this command. </p>

<p><strong>That is to say, if the executing time is beyond X seconds, the program will skip the command</strong>.</p>

<p>What's more, can other useful solution deal with my problem? Thanks in advance!</p>