You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
start_tls() difficult when using asyncio.start_server() #79156
bpo-36889: Merge StreamWriter and StreamReader into just asyncio.Stream
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/asvetlov'closed_at=Nonecreated_at=<Date2018-10-13.20:03:13.550>labels= ['3.11', 'type-feature', 'expert-asyncio']
title='start_tls() difficult when using asyncio.start_server()'updated_at=<Date2022-04-08.00:05:00.270>user='https://github.com/icgood'
There does not seem to be a public API for replacing the transport of the StreamReader / StreamWriter provided to the callback of a call to asyncio.start_server().
The only way I have found to use the new SSL transport is to update protected members of the StreamReaderProtocol object, e.g.:
One thing: I'm -1 on adding starttls to current stream api; let's add it only to the new one (same for sendfile)
icgood commented on May 9, 2019
icgoodmannequin
MannequinAuthor
More actions
I added start_tls() to StreamWriter. My implementation returns a new StreamWriter that should be used from then on, but it could be adapted to modify the current writer in-place (let me know).
I've added docs, an integration test, and done some additional "real-world" testing with an IMAP server I work on. Specifically, "openssl s_client -connect xxx -starttls imap" works like a charm, and no errors/warnings are logged on disconnect.
I believe stream transport should be replaced.
If you have time please do this change.
Also please take a look at bpo-36889 for merging StreamWriter and StreamReader.
It can simplify the replacement strategy.
Anyway, please keep your PR open at least.
The plan is: either merge your PR before writer/reader merging or land unified streams first and adopt the PR to new API.
Another thing that should be done before 3.8 feature freeze is support for sendfile in streams API. Hopefully, it is much simpler: no need for transport changing etc.
Activity
icgood commentedon Oct 13, 2018
There does not seem to be a public API for replacing the transport of the StreamReader / StreamWriter provided to the callback of a call to asyncio.start_server().
The only way I have found to use the new SSL transport is to update protected members of the StreamReaderProtocol object, e.g.:
asvetlov commentedon Oct 13, 2018
Thanks for raising the problem.
I'm in the middle of streams API refactoring.
https://github.com/asvetlov/cpython/blob/async-streams/Lib/asyncio/streams.py#L801-L812 is a draft.
A help is very appreciated.
Would you pick up this snippet and make a pull request with tests and documentation update?
1st1 commentedon Oct 13, 2018
One thing: I'm -1 on adding starttls to current stream api; let's add it only to the new one (same for sendfile)
icgood commentedon May 9, 2019
I added start_tls() to StreamWriter. My implementation returns a new StreamWriter that should be used from then on, but it could be adapted to modify the current writer in-place (let me know).
I've added docs, an integration test, and done some additional "real-world" testing with an IMAP server I work on. Specifically, "openssl s_client -connect xxx -starttls imap" works like a charm, and no errors/warnings are logged on disconnect.
asvetlov commentedon May 11, 2019
I believe stream transport should be replaced.
If you have time please do this change.
Also please take a look at bpo-36889 for merging StreamWriter and StreamReader.
It can simplify the replacement strategy.
Anyway, please keep your PR open at least.
The plan is: either merge your PR before writer/reader merging or land unified streams first and adopt the PR to new API.
Another thing that should be done before 3.8 feature freeze is support for sendfile in streams API. Hopefully, it is much simpler: no need for transport changing etc.
asvetlov commentedon May 27, 2019
Fixed by bpo-36889
icgood commentedon Oct 28, 2019
bpo-36889 was reverted, so this is not resolved.
I'm guessing this needs to be moved to 3.9 now too. Is my original PR worth revisiting? https://github.com/python/cpython/pull/13143/files
asvetlov commentedon Oct 28, 2019
I think it should be closed; Yuri thinks that current streams API is frozen for the sake of shiny brand new streams (don't exist yet).
gpshead commentedon Apr 8, 2022
https://discuss.python.org/t/need-reconsideration-of-bpo-34975-add-start-tls-method-to-streams-api/14720 would like to see this reconsidered. reopening.
gh-79156: Add start_tls() method to streams API (#91453)
kumaraditya303 commentedon May 20, 2022
Fixed by #91453