Better idea: start a `tractor.experimental` subpkg
parent
d29a915d48
commit
ffe88de53b
|
@ -5,19 +5,20 @@ import pytest
|
|||
import trio
|
||||
import tractor
|
||||
from tractor.testing import tractor_test
|
||||
from tractor.experimental import msgpub
|
||||
|
||||
|
||||
def test_type_checks():
|
||||
|
||||
with pytest.raises(TypeError) as err:
|
||||
@tractor.msg.pub
|
||||
@msgpub
|
||||
async def no_get_topics(yo):
|
||||
yield
|
||||
|
||||
assert "must define a `get_topics`" in str(err.value)
|
||||
|
||||
with pytest.raises(TypeError) as err:
|
||||
@tractor.msg.pub
|
||||
@msgpub
|
||||
def not_async_gen(yo):
|
||||
pass
|
||||
|
||||
|
@ -32,7 +33,7 @@ def is_even(i):
|
|||
_get_topics = None
|
||||
|
||||
|
||||
@tractor.msg.pub
|
||||
@msgpub
|
||||
async def pubber(get_topics, seed=10):
|
||||
|
||||
# ensure topic subscriptions are as expected
|
||||
|
@ -103,7 +104,7 @@ async def subs(
|
|||
await stream.aclose()
|
||||
|
||||
|
||||
@tractor.msg.pub(tasks=['one', 'two'])
|
||||
@msgpub(tasks=['one', 'two'])
|
||||
async def multilock_pubber(get_topics):
|
||||
yield {'doggy': 10}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# tractor: structured concurrent "actors".
|
||||
# Copyright 2018-eternity Tyler Goodlet.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
'''
|
||||
Experimental APIs and subsystems not yet validated to be included as
|
||||
built-ins.
|
||||
|
||||
This is a staging area for ``tractor.builtin``.
|
||||
|
||||
'''
|
||||
from ._pubsub import pub as msgpub
|
||||
|
||||
|
||||
__all__ = [
|
||||
'msgpub',
|
||||
]
|
|
@ -23,6 +23,7 @@ NOTE: this module is likely deprecated by the new bi-directional streaming
|
|||
support provided by ``tractor.Context.open_stream()`` and friends.
|
||||
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import inspect
|
||||
import typing
|
||||
from typing import Dict, Any, Set, Callable, List, Tuple
|
||||
|
@ -32,8 +33,9 @@ from async_generator import aclosing
|
|||
import trio
|
||||
import wrapt
|
||||
|
||||
from .log import get_logger
|
||||
from ._streaming import Context
|
||||
from ..log import get_logger
|
||||
from .._streaming import Context
|
||||
|
||||
|
||||
__all__ = ['pub']
|
||||
|
||||
|
@ -45,8 +47,11 @@ async def fan_out_to_ctxs(
|
|||
topics2ctxs: Dict[str, list],
|
||||
packetizer: typing.Callable = None,
|
||||
) -> None:
|
||||
"""Request and fan out quotes to each subscribed actor channel.
|
||||
"""
|
||||
'''
|
||||
Request and fan out quotes to each subscribed actor channel.
|
||||
|
||||
'''
|
||||
|
||||
def get_topics():
|
||||
return tuple(topics2ctxs.keys())
|
||||
|
Loading…
Reference in New Issue