Added workaround for warning in `threading` module after `TestInterrupt` by lostmsu · Pull Request #1560 · pythonnet/pythonnet

Also: avoid using dynamic in GetPythonThreadID

What does this implement/fix? Explain your changes.

This should put us to peace in regards to this warning in CI on MacOS X Python 3.7:

Exception ignored in: <module 'threading' from '/Users/runner/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/threading.py'>
Traceback (most recent call last):
  File "/Users/runner/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/threading.py", line 1292, in _shutdown
    assert tlock.locked()
AssertionError: 

It happens when the main Python thread never imports threading module, while secondary threads do.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change