Better port collision management for the functional tests
Summary:
On a machine with lots of CPUs, it's is very possible to generate port collision by simply running to many tests. The port computation will wrap up and collide with a test which is still running. To avoid this, we change to strategy to use port skips by range depending on the CPU count.
While at it, I also removed the global and renamed it for clarity, wrapping it into a class to make mypy happy (function attributes are not supported but class attributes are).
Test Plan:
On a 32 core machine:
./test/functional/test_runner.py
Reviewers: #bitcoin_abc, roqqit, PiRK
Reviewed By: #bitcoin_abc, roqqit, PiRK
Subscribers: PiRK
Differential Revision: https://reviews.bitcoinabc.org/D17661