You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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:
+ python -m coverage run -m unittest discover
..........................EException in thread Serial server thread:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/atlassian/pipelines/agent/build/uart3br/_serial_server.py", line 50, in run
self.socket.bind((self.HOST, self.PORT))
OSError: [Errno 98] Address already in use
# ...
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:
OSError: [Errno 98] Address already in use
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.
Figured it out.
I tested the pipeline locally with Docker, where I ran into the same errors. Apparently there is something with the Python image / Debian / Docker (or a combination) that does not allow rapid opening and closing of sockets.
Instead I restructured my tests to only open and close the server socket once (using `setUpClass()` instead of `setUp()`).
Working pipeline: https://bitbucket.org/ctw-bw/micropython-dummy-modules/addon/pipelines/home#!/results/9
So there is nothing keeping sockets from working.
Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.