Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Edited

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

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.

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

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
Community showcase
Published in Apps & Integrations

🍂📹 Apptoberfest demo contest roundup: vote for your favorite demos!

Hi Community! The submissions are in (and listed below) for the 🍻🍂Apptoberfest🍂🍻 Demo Competition and it’s time for you to place your votes for the best: Analytics & reporting app demo ...

267 views 7 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you