Skip to content

Implement timeouts (#64) - #89

Merged
mehaase merged 2 commits into
masterfrom
add_timeouts
Nov 17, 2018
Merged

mehaase merged 2 commits into
masterfrom
add_timeouts

Conversation

@mehaase

@mehaase mehaase commented Nov 14, 2018

Copy link
Copy Markdown
Contributor

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

coveralls commented Nov 14, 2018 •

Copy link
Copy Markdown

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

mehaase commented Nov 14, 2018

Copy link
Copy Markdown
Contributor Author

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.

Comment thread docs/recipes.rst Resolved
Comment thread docs/timeouts.rst Resolved
Comment thread docs/timeouts.rst Outdated

.. note::

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

Copy link
Copy Markdown
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
Copy Markdown
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?

Comment thread docs/timeouts.rst Outdated
you may disable them or use lower-level APIs if you want more control over the
behavior.

Built-in Client Timeouts

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread docs/timeouts.rst Outdated
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
Copy Markdown
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?

Comment thread docs/timeouts.rst Resolved
Comment thread tests/test_connection.py Resolved
Comment thread tests/test_connection.py Resolved
Comment thread tests/test_connection.py Resolved
Comment thread trio_websocket/_impl.py 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