Stop using as much closures
Use a custom tractor branch that fixes a `maybe_open_context` re entrant related bugsize_in_shm_token
parent
34fb497eb4
commit
e97dd1cbdb
|
@ -557,15 +557,9 @@ async def maybe_open_feed_handler() -> trio.abc.ReceiveStream:
|
||||||
yield fh
|
yield fh
|
||||||
|
|
||||||
|
|
||||||
@acm
|
async def aio_price_feed_relay(
|
||||||
async def open_price_feed(
|
fh: FeedHandler,
|
||||||
instrument: str
|
instrument: Symbol,
|
||||||
) -> trio.abc.ReceiveStream:
|
|
||||||
|
|
||||||
# XXX: hangs when going into this ctx mngr
|
|
||||||
async with maybe_open_feed_handler() as fh:
|
|
||||||
|
|
||||||
async def relay(
|
|
||||||
from_trio: asyncio.Queue,
|
from_trio: asyncio.Queue,
|
||||||
to_trio: trio.abc.SendChannel,
|
to_trio: trio.abc.SendChannel,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -598,7 +592,7 @@ async def open_price_feed(
|
||||||
fh.add_feed(
|
fh.add_feed(
|
||||||
DERIBIT,
|
DERIBIT,
|
||||||
channels=[TRADES, L1_BOOK],
|
channels=[TRADES, L1_BOOK],
|
||||||
symbols=[instrument],
|
symbols=[piker_sym_to_cb_sym(instrument)],
|
||||||
callbacks={
|
callbacks={
|
||||||
TRADES: _trade,
|
TRADES: _trade,
|
||||||
L1_BOOK: _l1
|
L1_BOOK: _l1
|
||||||
|
@ -612,14 +606,19 @@ async def open_price_feed(
|
||||||
# sync with trio
|
# sync with trio
|
||||||
to_trio.send_nowait(None)
|
to_trio.send_nowait(None)
|
||||||
|
|
||||||
try:
|
|
||||||
await asyncio.sleep(float('inf'))
|
await asyncio.sleep(float('inf'))
|
||||||
|
|
||||||
except asyncio.exceptions.CancelledError:
|
|
||||||
...
|
|
||||||
|
|
||||||
|
@acm
|
||||||
|
async def open_price_feed(
|
||||||
|
instrument: str) -> trio.abc.ReceiveStream:
|
||||||
|
async with maybe_open_feed_handler() as fh:
|
||||||
async with to_asyncio.open_channel_from(
|
async with to_asyncio.open_channel_from(
|
||||||
relay
|
partial(
|
||||||
|
aio_price_feed_relay,
|
||||||
|
fh,
|
||||||
|
instrument
|
||||||
|
)
|
||||||
) as (first, chan):
|
) as (first, chan):
|
||||||
yield chan
|
yield chan
|
||||||
|
|
||||||
|
@ -642,14 +641,11 @@ async def maybe_open_price_feed(
|
||||||
else:
|
else:
|
||||||
yield feed
|
yield feed
|
||||||
|
|
||||||
@acm
|
|
||||||
async def open_order_feed(
|
|
||||||
instrument: List[str]
|
|
||||||
) -> trio.abc.ReceiveStream:
|
|
||||||
|
|
||||||
async with maybe_open_feed_handler() as fh:
|
|
||||||
|
|
||||||
async def relay(
|
async def aio_order_feed_relay(
|
||||||
|
fh: FeedHandler,
|
||||||
|
instrument: Symbol,
|
||||||
from_trio: asyncio.Queue,
|
from_trio: asyncio.Queue,
|
||||||
to_trio: trio.abc.SendChannel,
|
to_trio: trio.abc.SendChannel,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -662,7 +658,7 @@ async def open_order_feed(
|
||||||
fh.add_feed(
|
fh.add_feed(
|
||||||
DERIBIT,
|
DERIBIT,
|
||||||
channels=[FILLS, ORDER_INFO],
|
channels=[FILLS, ORDER_INFO],
|
||||||
symbols=[instrument],
|
symbols=[instrument.upper()],
|
||||||
callbacks={
|
callbacks={
|
||||||
FILLS: _fill,
|
FILLS: _fill,
|
||||||
ORDER_INFO: _order_info,
|
ORDER_INFO: _order_info,
|
||||||
|
@ -676,17 +672,24 @@ async def open_order_feed(
|
||||||
# sync with trio
|
# sync with trio
|
||||||
to_trio.send_nowait(None)
|
to_trio.send_nowait(None)
|
||||||
|
|
||||||
try:
|
|
||||||
await asyncio.sleep(float('inf'))
|
await asyncio.sleep(float('inf'))
|
||||||
|
|
||||||
except asyncio.exceptions.CancelledError:
|
|
||||||
...
|
|
||||||
|
|
||||||
|
@acm
|
||||||
|
async def open_order_feed(
|
||||||
|
instrument: List[str]
|
||||||
|
) -> trio.abc.ReceiveStream:
|
||||||
|
async with maybe_open_feed_handler() as fh:
|
||||||
async with to_asyncio.open_channel_from(
|
async with to_asyncio.open_channel_from(
|
||||||
relay
|
partial(
|
||||||
|
aio_order_feed_relay,
|
||||||
|
fh,
|
||||||
|
instrument
|
||||||
|
)
|
||||||
) as (first, chan):
|
) as (first, chan):
|
||||||
yield chan
|
yield chan
|
||||||
|
|
||||||
|
|
||||||
@acm
|
@acm
|
||||||
async def maybe_open_order_feed(
|
async def maybe_open_order_feed(
|
||||||
instrument: str
|
instrument: str
|
||||||
|
@ -696,7 +699,8 @@ async def maybe_open_order_feed(
|
||||||
async with maybe_open_context(
|
async with maybe_open_context(
|
||||||
acm_func=open_order_feed,
|
acm_func=open_order_feed,
|
||||||
kwargs={
|
kwargs={
|
||||||
'instrument': instrument
|
'instrument': instrument,
|
||||||
|
'fh': fh
|
||||||
},
|
},
|
||||||
key=f'{instrument}-order',
|
key=f'{instrument}-order',
|
||||||
) as (cache_hit, feed):
|
) as (cache_hit, feed):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# we require a pinned dev branch to get some edge features that
|
# we require a pinned dev branch to get some edge features that
|
||||||
# are often untested in tractor's CI and/or being tested by us
|
# are often untested in tractor's CI and/or being tested by us
|
||||||
# first before committing as core features in tractor's base.
|
# first before committing as core features in tractor's base.
|
||||||
-e git+https://github.com/goodboy/tractor.git@master#egg=tractor
|
-e git+https://github.com/goodboy/tractor.git@reentrant_moc#egg=tractor
|
||||||
|
|
||||||
# `pyqtgraph` peeps keep breaking, fixing, improving so might as well
|
# `pyqtgraph` peeps keep breaking, fixing, improving so might as well
|
||||||
# pin this to a dev branch that we have more control over especially
|
# pin this to a dev branch that we have more control over especially
|
||||||
|
|
Loading…
Reference in New Issue