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

Get rid of legacy class StreamWriter #2109 #2651

Merged
merged 11 commits into from
Jan 11, 2018
Merged

Conversation

pfreixes
Copy link
Contributor

@pfreixes pfreixes commented Jan 10, 2018

What do these changes do?

Legacy StreamWriter class as a pure proxy of the transport and the protocol is
no longer needed. All of the functionalities that were behind this class
has been moved to the PayloadWriter class.

Some changes that have to be considered that impacted by this change

  • TCP Operations have been isolated in a module rather than move them
    into the PayloadWriter class. All of these operations have been simplified and state less.

  • WebSocketWriter class had a dependency with the StreamWriter, to get rid of
    that dependency the constructor has been modified to take the protocol
    and the transport.

A next step changing the name of the PayLoadWriter class for the StreamWriter - it reborn!- might be considered, making it consistent with the reader side.

Are there changes in behavior for the user?

No

Related issue number

#2109

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • [] Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

Legacy StreamWriter as a pure proxy of the transport and the protocol is
no longer needed. All of the functionalities that were behind this class
has been moved to the PayloadWriter.

Some changes that have to be considered that impacted during this change
* TCP Operations have been isolated in a module rather than move them
into the PayloadWriter
* WebSocketWriter had a dependency with the StreamWriter, to get rid of
that dependency the constructor has been modified to take the protocol
and the transport.

A next step changing the name PayLoadWriter for the StreamWriter to have
consistency with the reader part, might be considered.
@pfreixes pfreixes changed the title Get rid of legacy StreamWriter (#2623) Get rid of legacy StreamWriter #2623 Jan 10, 2018
@pfreixes pfreixes changed the title Get rid of legacy StreamWriter #2623 Get rid of legacy StreamWriter #2109 Jan 10, 2018
@pfreixes pfreixes changed the title Get rid of legacy StreamWriter #2109 Get rid of legacy class StreamWriter #2109 Jan 10, 2018
@fafhrd91
Copy link
Member

looks good to me

return self._transport

@property
def protocol(self):
return self._protocol
Copy link
Member

Choose a reason for hiding this comment

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

Please add a test for the property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

PayLoadWriter -> StreamWriter renaming sounds reasonable too

@codecov-io
Copy link

codecov-io commented Jan 10, 2018

Codecov Report

Merging #2651 into master will increase coverage by 0.06%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2651      +/-   ##
==========================================
+ Coverage   97.92%   97.98%   +0.06%     
==========================================
  Files          38       39       +1     
  Lines        7272     7245      -27     
  Branches     1262     1257       -5     
==========================================
- Hits         7121     7099      -22     
+ Misses         47       45       -2     
+ Partials      104      101       -3
Impacted Files Coverage Δ
aiohttp/http.py 100% <ø> (ø) ⬆️
aiohttp/client_proto.py 94.57% <100%> (-0.09%) ⬇️
aiohttp/http_websocket.py 98.61% <100%> (ø) ⬆️
aiohttp/http_writer.py 100% <100%> (+0.75%) ⬆️
aiohttp/web_protocol.py 91.57% <100%> (+2.23%) ⬆️
aiohttp/client_reqrep.py 97.36% <100%> (ø) ⬆️
aiohttp/web_fileresponse.py 97.87% <50%> (-0.02%) ⬇️
aiohttp/tcp_helpers.py 89.28% <89.28%> (ø)

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 74810c2...884a4cf. Read the comment docs.

@asvetlov
Copy link
Member

Another question: why do you return a value from tcp_cork/tcp_nodelay but never use it in aiohttp code?
Let's drop this functionality.
Tests can check a real TCP option by getsockopt call instead of checking the return value.

@pfreixes
Copy link
Contributor Author

@asvetlov removed the value returned by the TCP operations. My fault Ive ended up changing the code to have an easy way to test the functions, once these have become stateless there is some edge cases where I cant see how to assert properly. For example the case of the socket None.
Any idea how to improve this [1]?

[1] 87928be#diff-ef69e535e777102409aee677f44b4137R75

@asvetlov
Copy link
Member

You can monkey-patch socket object to make sure that its methods are not called but I think current code is good enough.

@asvetlov asvetlov merged commit f570fed into master Jan 11, 2018
@asvetlov asvetlov deleted the remove_streamwriter branch January 11, 2018 09:37
@asvetlov
Copy link
Member

Thanks!

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bot:chronographer:provided There is a change note present in this PR outdated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants