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

issue 247, any cancelation inside the socket will leave it closed #574

Merged
merged 5 commits into from
Jul 28, 2018

Conversation

monobot
Copy link
Contributor

@monobot monobot commented Jul 28, 2018

No description provided.

@codecov
Copy link

codecov bot commented Jul 28, 2018

Codecov Report

Merging #574 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #574      +/-   ##
==========================================
+ Coverage   99.27%   99.27%   +<.01%     
==========================================
  Files          89       89              
  Lines       10617    10628      +11     
  Branches      747      747              
==========================================
+ Hits        10540    10551      +11     
  Misses         59       59              
  Partials       18       18
Impacted Files Coverage Δ
trio/tests/test_socket.py 100% <100%> (ø) ⬆️
trio/_socket.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45b4e58...ce84a68. Read the comment docs.

Copy link
Contributor

@sorcio sorcio left a comment

Choose a reason for hiding this comment

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

👍 I think this is good and the test is testing the right thing. I should note that I accidentally misguided you (when we discussed this at EuroPython) by saying that the connect method can only be cancelled in two points, but there is a third one that I didn't notice. The async with _try_sync() line is one more point where cancellation can happen, on enter. Probably it's fine and we don't want to add a different test case, but I think I should let you know because I said something different before, and maybe you want to give a second look at the code.

When you feel you're done, can you view the steps in the contributing guide here? https://trio.readthedocs.io/en/latest/contributing.html#preparing-pull-requests
Specifically running yapf and adding a newsfragment :)

@@ -10,6 +10,7 @@
from .. import _socket as _tsocket
from .. import socket as tsocket
from .._socket import _NUMERIC_ONLY, _try_sync
from .._timeouts import sleep
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can avoid importing from _timeouts here if in the test below you call _core.checkpoint() rather than sleep.

@@ -506,6 +507,7 @@ class MySocket(stdlib_socket.socket):
with assert_checkpoints():
with pytest.raises(TypeError):
await ta.recv("haha")

Copy link
Contributor

Choose a reason for hiding this comment

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

Careful, you're introducing spurious whitespace :)

@@ -515,6 +517,7 @@ class MySocket(stdlib_socket.socket):
nursery.start_soon(do_successful_blocking_recv)
await wait_all_tasks_blocked()
b.send(b"2")

Copy link
Contributor

Choose a reason for hiding this comment

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

More spurious whitespace


async def _resolve_remote_address(self, *args, **kwargs):
cancel_scope.cancel()
await sleep(.001)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here is where I would recommend to use _core.checkpoint().

@monobot
Copy link
Contributor Author

monobot commented Jul 28, 2018

@sorcio switched the sleep for the checkpoint and removed the extra lines you mentioned
Also added the newsfragments file with the issue "247.bugfix.rst"

@sorcio sorcio merged commit fd0d877 into python-trio:master Jul 28, 2018
@sorcio sorcio mentioned this pull request Jul 28, 2018
@njsmith
Copy link
Member

njsmith commented Jul 28, 2018

Thanks, and welcome! 🎉 🎂 And, no pressure, but if you'd like to keep contributing then we'd love to have you, so I'm sending you a github invite now. You can read more about this in our contributing documentation.

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.

None yet

3 participants