user24556: I was looking at ../qa/rpc-tests/util.py in order to figure out how arbitrary ports are assigned to each created node.
In the first lines of the code it says:

...def p2p_port(n):return 11000 + n + os.getpid()%999...

So I'm wondering what exactly os.getpid()%999 does?
Is it instantly looking for a free port?
Thanks in advance!

user18227: os.getpid() in Python is getting the current process id. The processor id is 'random-ish', in that running the entire test several times will result in a different pid, but within the same test the pid will remain constant. 
The % operator is the modulus operator, which is essentially chopping off all but the last 3 digits of the processor id. 
Together os.getpid() % 999 is getting a constant offset and ignoring all but the last 3 digits. This new 3 digit number of added to the constant 11000 to return the port number to use. 

24556: <p>I was looking at <code>../qa/rpc-tests/util.py</code> in order to figure out how arbitrary ports are assigned to each created node.
In the first lines of the code it says:</p>

<blockquote>
  <p>...<br/>def p2p_port(n):<br/>return 11000 + n + <strong>os.getpid()%999</strong><br/>...</p>
</blockquote>

<p>So I'm wondering what exactly os.getpid()%999 does?
Is it instantly looking for a free port?</p>

<p>Thanks in advance!</p>
 18227: <p><code>os.getpid()</code> in Python is getting the <a href="https://docs.python.org/2/library/os.html" rel="nofollow noreferrer">current process id</a>. The processor id is 'random-ish', in that running the entire test several times will result in a different pid, but within the same test the pid will remain constant. </p>

<p>The <code>%</code> operator is the <a href="https://stackoverflow.com/questions/4432208/how-does-work-in-python">modulus operator</a>, which is essentially chopping off all but the last 3 digits of the processor id. </p>

<p>Together <code>os.getpid() % 999</code> is getting a constant offset and ignoring all but the last 3 digits. This new 3 digit number of added to the constant 11000 to return the port number to use. </p>
