title: Python sudo privileges
body: <p>I have a script (<code>A.py</code>) that will spawn new processes (<code>B.py</code>) dynamically but those scripts need to be created as <code>root</code>.  If I run </p>
  
  <pre><code>$ python A.py
  </code></pre>
  
  <p>as a normal user, then when I run</p>
  
  <pre><code>&gt;&gt;&gt; subprocess.Popen('sudo nohup python B.py &amp;') 
  </code></pre>
  
  <p>I'll need to enter the <code>root</code> password to start.  I don't really want to do that.</p>
  
  <hr>
  
  <p>Now if I run the first script as <code>root</code></p>
  
  <pre><code>$ sudo python A.py
  </code></pre>
  
  <p>then I'll be able to run </p>
  
  <pre><code>&gt;&gt;&gt; subprocess.Popen('nohup python B.py &amp;')
  </code></pre>
  
  <p>like normal.  The thing that concerns me is a timeout period with the sudo and it will drop to normal privileges then when <code>A.py</code> want to spawn/kill a process it will ask for a password and stop working as intended.</p>
  
  <ol>
  <li>Will running <code>sudo python A.py</code> keep root privileges for the life of the script, or will it lose it with the <code>sudo timeout</code> (I believe default is 15min) like a normal terminal?</li>
  <li>Is there a better way of doing this?</li>
  </ol>