Skip to content

Commit

Permalink
Enable stream backpressure by default, add MsgStream.ctx: Context
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Dec 12, 2022
1 parent 5dc07f0 commit 304ee6c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tractor/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ReceiveMsgStream(trio.abc.ReceiveChannel):
'''
def __init__(
self,
ctx: 'Context', # typing: ignore # noqa
ctx: Context, # typing: ignore # noqa
rx_chan: trio.MemoryReceiveChannel,
_broadcaster: Optional[BroadcastReceiver] = None,

Expand All @@ -82,6 +82,9 @@ def __init__(
self._eoc: bool = False
self._closed: bool = False

def ctx(self) -> Context:
return self._ctx

# delegate directly to underlying mem channel
def receive_nowait(self):
msg = self._rx_chan.receive_nowait()
Expand Down Expand Up @@ -381,7 +384,7 @@ class Context:
# only set on the callee side
_scope_nursery: Optional[trio.Nursery] = None

_backpressure: bool = False
_backpressure: bool = True

async def send_yield(self, data: Any) -> None:

Expand Down

0 comments on commit 304ee6c

Please sign in to comment.