@@ -503,14 +503,20 @@ def connection_made(self, transport: BaseTransport) -> None:
503
503
The transport argument is the transport representing the write side of the connection.
504
504
"""
505
505
self .transport = transport # type: ignore[assignment]
506
+ self .transport .set_write_buffer_limits (MAX_MESSAGE_SIZE , MAX_MESSAGE_SIZE ) # type: ignore
506
507
507
508
async def write (self , message : bytes ) -> None :
508
509
"""Write a message to this connection's transport."""
509
510
if self .transport .is_closing ():
510
511
raise OSError ("Connection is closed" )
512
+ try :
513
+ self .transport .resume_reading ()
514
+ # Known bug in SSL Protocols, fixed in Python 3.11: https://github.com/python/cpython/issues/89322
515
+ except AttributeError :
516
+ raise OSError ("connection is already closed" ) from None
511
517
self .transport .write (message )
512
- await self ._drain_helper ()
513
- self .transport .resume_reading ()
518
+ # await self._drain_helper()
519
+ # self.transport.resume_reading()
514
520
515
521
async def read (self , request_id : Optional [int ], max_message_size : int ) -> tuple [bytes , int ]:
516
522
"""Read a single MongoDB Wire Protocol message from this connection."""
@@ -698,9 +704,9 @@ def pause_writing(self) -> None:
698
704
def resume_writing (self ) -> None :
699
705
assert self ._paused
700
706
self ._paused = False
701
-
702
- if self ._drain_waiter and not self ._drain_waiter .done ():
703
- self ._drain_waiter .set_result (None )
707
+ #
708
+ # if self._drain_waiter and not self._drain_waiter.done():
709
+ # self._drain_waiter.set_result(None)
704
710
705
711
def connection_lost (self , exc : Exception | None ) -> None :
706
712
self ._connection_lost = True
@@ -719,15 +725,15 @@ def connection_lost(self, exc: Exception | None) -> None:
719
725
else :
720
726
self ._closed .set_exception (exc )
721
727
722
- # Wake up the writer(s) if currently paused.
723
- if not self ._paused :
724
- return
725
-
726
- if self ._drain_waiter and not self ._drain_waiter .done ():
727
- if exc is None :
728
- self ._drain_waiter .set_result (None )
729
- else :
730
- self ._drain_waiter .set_exception (exc )
728
+ # # Wake up the writer(s) if currently paused.
729
+ # if not self._paused:
730
+ # return
731
+ #
732
+ # if self._drain_waiter and not self._drain_waiter.done():
733
+ # if exc is None:
734
+ # self._drain_waiter.set_result(None)
735
+ # else:
736
+ # self._drain_waiter.set_exception(exc)
731
737
732
738
async def _drain_helper (self ) -> None :
733
739
if self ._connection_lost :
0 commit comments