Kyle Stanley <aeros...@gmail.com> added the comment:

> Do we really want this to be just an assert, or do we want to raise another 
> type of exception?

IMO, we should look into converting this into an exception. Mistakenly having a 
task await StreamWriter.drain() at the same time as another is calling 
StreamWriter.write() does seem like a reasonable programming error that should 
preferably have an informative error message. Optimally, assertions shouldn't 
occur from normal programming errors in production.

The tricky part is figuring out how to implement it properly. I'm not 100% 
certain that we can make any guarantees that when the _drain_waiter future 
hasn't been cancelled and not set to None that someone is mistakenly doing the 
above. It could potentially trigger from other errors.

Either way though, I think just adding a message to the assert could end up 
being misleading if someone else encounters this in production for another 
reason. Instead, I think we could leave a comment there for now and in the long 
term figure out how to properly implement the exception or warning. We also 
need a reliable way to reproduce it, mainly for the purpose of writing a new 
test to ensure the exception is correctly triggered when someone makes the 
above programming error.

----------
nosy: +aeros

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40124>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to