Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement timeouts (#64) #89

Merged
merged 2 commits into from
Nov 17, 2018
Merged

Implement timeouts (#64) #89

merged 2 commits into from
Nov 17, 2018

Conversation

mehaase
Copy link
Contributor

@mehaase mehaase commented Nov 14, 2018

This includes tests and docs.

I also started thinking about how to make tests more deterministic, i.e. #88. I don't have a full solution to that here, but I did write these new tests more carefully and included some comments on the test module that should guide additional effort to reduce race conditions in the test.

This includes tests and docs.
@mehaase mehaase requested a review from belm0 November 14, 2018 21:17
@coveralls
Copy link

coveralls commented Nov 14, 2018

Pull Request Test Coverage Report for Build 98

  • 32 of 36 (88.89%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 92.487%

Changes Missing Coverage Covered Lines Changed/Added Lines %
trio_websocket/_impl.py 32 36 88.89%
Files with Coverage Reduction New Missed Lines %
trio_websocket/_impl.py 1 92.71%
Totals Coverage Status
Change from base Build 92: -0.2%
Covered Lines: 357
Relevant Lines: 386

💛 - Coveralls

@mehaase
Copy link
Contributor Author

mehaase commented Nov 14, 2018

I forgot to mention that I modified the connection logging a bit, it now prints out server-0 or client-0 instead of conn#0, which makes it a lot easier for me to understand what's going on when tests don't work.

docs/recipes.rst Show resolved Hide resolved
docs/timeouts.rst Outdated Show resolved Hide resolved

.. note::

The built-in timeouts do not affect the contents of the block! In this
Copy link
Member

Choose a reason for hiding this comment

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

maybe "not affect websocket messaging within the context manger scope"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you objecting to the phrase "affect the contents" or the term "block"?

I think the former is accurate, in the sense that nothing you do inside that block will be affected by these timeout arguments, i.e. even if you trio.sleep(math.inf) that wouldn't time out. It would be overly narrow to say that the timeouts don't affect messaging.

As for "block", I'm uncertain. I originally wrote something more verbose like "context manager block" but it felt unwieldy to keep using that phrase. Maybe spell it out once and then abbreviate it as CM block?

you may disable them or use lower-level APIs if you want more control over the
behavior.

Built-in Client Timeouts
Copy link
Member

Choose a reason for hiding this comment

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

I prefer only capitalizing the first word in headings: less of a distracting artifact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not opposed to the style change, but all of the other documentation has headings that are capitalized like this.

message, then the client will block indefinitely on ``ws.get_message()``.
Placing timeouts inside blocks is discussed below.

What if you decided that you really wanted to manage the timeouts yourself? The
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps open with this example, as motivation for adding timeouts to the API, and to make it clear what the API timeouts are doing under the hood?

docs/timeouts.rst Outdated Show resolved Hide resolved
tests/test_connection.py Show resolved Hide resolved
tests/test_connection.py Show resolved Hide resolved
tests/test_connection.py Show resolved Hide resolved
trio_websocket/_impl.py Outdated Show resolved Hide resolved
@mehaase mehaase merged commit a71aaac into master Nov 17, 2018
@mehaase mehaase deleted the add_timeouts branch November 17, 2018 14:22
@mehaase mehaase mentioned this pull request Nov 17, 2018
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.

3 participants