Python3.8 time.sleep() fails on unit test

Hiro Nakamata February 11, 2021

Hi there, I'm using python:3.8 image and trying to run unit test with pytest.

When time.sleep() method is called in order to retry http connection, the step abruptly stops without any error and log.

How can I debug or resolve this? Thanks

 

Pytest command

pipenv run pytest --capture=tee-sys

 

Code:

try:
with socket.create_connection((host, port), timeout=timeout):
logger.info(f"port={port} is ready")
break
except OSError as ex:
try:
logger.info("Performing an action which may throw an exception.")
logger.info(time.asctime())
time.sleep(3)
except:
logger.info("Everything looks great!")
finally:
logger.info(
"Finally is called directly after executing the try statement whether an exception is thrown or not.")

 

 

Output on the pipeline console:

Screen Shot 2021-02-12 at 3.19.50 PM.png

1 answer

0 votes
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 12, 2021

Hey @Hiro Nakamata , welcome to the Atlassian community.

Can you make pytest to be more verbose with the output and to do all logging on standard output and error? This should normally reveal more.

In general it means that an error occurred. 

You can debug your pipeline locally, please see: Debug pipelines locally with Docker and the other documents in that section.

Running the pipeline locally is great for debugging, some tooling like bbrun or pipelines exist.

Hiro Nakamata February 12, 2021

@ktomk thanks for the reply. I added source code and logs

ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2021

I would run this locally inside a container and then see if it is reproducible.

And if I may ask, why may 

time.sleep(3)

 throw an exception?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events