I am developing an application that uses the `sockets` package. I included `unittest` unit tests to test the application.
The complete bitbucket-pipelines.yml:
image: python:3.8
pipelines:
default:
- step:
script:
- pip install --upgrade pip
- pip install --upgrade sockets coverage
- git submodule update --init
- python -m coverage run -m unittest discover
- bash <(curl -s https://codecov.io/bash)
However, the pipeline throws errors when the unit tests are being performed:
<span>+ python -m coverage run -m unittest discover<br>..........................EException in thread Serial server thread:<br>Traceback (most recent call last):<br>File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner<br>self.run()<br>File "/opt/atlassian/pipelines/agent/build/uart3br/_serial_server.py", line 50, in run<br>self.socket.bind((self.HOST, self.PORT))<br>OSError: [Errno 98] Address already in use<br><br># ...</span>
The complete pipe (and source): https://bitbucket.org/ctw-bw/micropython-dummy-modules/addon/pipelines/home#!/results/6
Of course the tests pass without problems on my computer (Windows 10, Python 3.8).
The socket creation looks like:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Set option to allow instant socket reuse after shutdown
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.bind(('127.0.0.1', 52184))
self.socket.listen()
# ...
The error trace is a little hard to follow, but two different errors are being throws:
<span>OSError: [Errno 98] Address already in use</span>
and
ConnectionRefusedError: [Errno 111] Connection refused
I was wondering if other people have had experience with this and what could be the solution to this problem.