Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 28, 2019

Add timeout constants to test.support:

  • LOOPBACK_TIMEOUT
  • INTERNET_TIMEOUT
  • SHORT_TIMEOUT
  • LONG_TIMEOUT

https://bugs.python.org/issue38614

@vstinner
Copy link
Member Author

Somehow related, in 2014, I tried to make time.sleep() calls configurable in tests: https://bugs.python.org/issue20910

@vstinner
Copy link
Member Author

@pablogsal: Would you mind to review this PR?

I'm not sure about the documentation of SHORT_TIMEOUT vs LONG_TIMEOUT.

LONG_TIMEOUT is 10 times larger than SHORT_TIMEOUT.

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @vstinner ! 🎉

I left some comments regarding style and minor nits!

Copy link
Member

@pablogsal pablogsal Oct 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should we add markup links to connect(), recv()...?

Basically `connect` -> :meth:`socket.socket.connect`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps :meth:~socket.socket.connect to avoid showing the fully-qualified name,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markup link to socket.socket?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps not needed if the methods are linked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Usually, a timeout using INTERNET_TIMEOUT should not mark a test a failed,
Usually, a timeout using INTERNET_TIMEOUT should not mark a test as failed,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: link to transient_internet if it makes sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
slower. It is not designed to measure a function performance.
It is not designed to measure a function performance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enough to reduce the risk of test failure on the slowest Python buildbot
enough to reduce the risk of test failure on the slowest Python buildbot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# For slowest buildbot worker, increase SHORT_TIMEOUT and LONG_TIMEOUT
# For a slow buildbot worker, increase SHORT_TIMEOUT and LONG_TIMEOUT

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# long enough to prevent test failure: it takes an account that the client and
# long enough to prevent test failure: it takes into account that the client and

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prevent test failure: it takes an account that the client and the server can
prevent test failure: it takes into account that the client and the server can

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Usually, a timeout using INTERNET_TIMEOUT should not mark a test a failed,
# Usually, a timeout using INTERNET_TIMEOUT should not mark a test as failed,

@pablogsal
Copy link
Member

pablogsal commented Oct 30, 2019

I'm not sure about the documentation of SHORT_TIMEOUT vs LONG_TIMEOUT.

Hummmm, maybe:

.. data:: SHORT_TIMEOUT
   Timeout in seconds that can be used to detect when a test hangs. It can be used
   in the average buildbots and is preferable over :data:`LONG_TIMEOUT` as it makes
   smaller pauses producing smaller run times for the test suite.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps :meth:~socket.socket.connect to avoid showing the fully-qualified name,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps not needed if the methods are linked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this special value rather than None, as in the other cases? Is it to support None as an actual timeout value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one test_socket test which requires timeout=None.

Add timeout constants to test.support:

* LOOPBACK_TIMEOUT
* INTERNET_TIMEOUT
* SHORT_TIMEOUT
* LONG_TIMEOUT
@vstinner
Copy link
Member Author

@pablogsal: I rephased the documentation to better distinguish SHORT and LONG timeout. Does it sound better to you? I took your review in account. I checked manually the HTML documentation to ensure that it's rendered properly ;-)

I revert changes to use new timeouts, except test_socket and _test_multiprocessing to make this PR easier to review. I will write more PRs to use the new constants, I start to modify tons of tests, I prefer to have separated PRs to make them easier to review.

@pablogsal
Copy link
Member

Does it sound better to you?

Much better indeed!

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

@vstinner vstinner merged commit 24c6258 into python:master Oct 30, 2019
@vstinner vstinner deleted the support_timeout branch October 30, 2019 11:41
jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request Dec 5, 2019
Add timeout constants to test.support:

* LOOPBACK_TIMEOUT
* INTERNET_TIMEOUT
* SHORT_TIMEOUT
* LONG_TIMEOUT
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
Add timeout constants to test.support:

* LOOPBACK_TIMEOUT
* INTERNET_TIMEOUT
* SHORT_TIMEOUT
* LONG_TIMEOUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants