Example #1
0
def run(item_group, stream, args):
    tasks = collections.deque()
    if args.heaps is None:
        rep = itertools.repeat(False)
    else:
        rep = itertools.chain(itertools.repeat(False, args.heaps), [True])
    for is_end in rep:
        if len(tasks) >= 2:
            yield From(trollius.wait([tasks.popleft()]))
        if is_end:
            task = trollius.async(stream.async_send_heap(item_group.get_end()))
        else:
            for item in item_group.values():
                item.version += 1
            task = trollius.async(stream.async_send_heap(item_group.get_heap()))
        tasks.append(task)
    while len(tasks) > 0:
        yield From(trollius.wait([tasks.popleft()]))
Example #2
0
def run(item_group, stream, args):
    tasks = collections.deque()
    if args.heaps is None:
        rep = itertools.repeat(False)
    else:
        rep = itertools.chain(itertools.repeat(False, args.heaps), [])
    for is_end in rep:
        if len(tasks) >= 2:
            yield From(trollius.wait([tasks.popleft()]))
        if is_end:
            task = trollius. async (stream.async_send_heap(
                item_group.get_end()))
        else:
            for item in item_group.values():
                item.version += 1
            task = trollius. async (stream.async_send_heap(
                item_group.get_heap()))
        tasks.append(task)
    while len(tasks) > 0:
        yield From(trollius.wait([tasks.popleft()]))
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import spead2
import spead2.send
import spead2.send.trollius
import logging
import numpy as np
import trollius

logging.basicConfig(level=logging.INFO)

thread_pool = spead2.ThreadPool()
stream = spead2.send.trollius.UdpStream(thread_pool, "127.0.0.1", 8888,
                                        spead2.send.StreamConfig(rate=1e7))
del thread_pool  # Make sure this doesn't crash anything

shape = (40, 50)
ig = spead2.send.ItemGroup(
    flavour=spead2.Flavour(4, 64, 48, spead2.BUG_COMPAT_PYSPEAD_0_5_2))
item = ig.add_item(0x1234, 'foo', 'a foo item', shape=shape, dtype=np.int32)
item.value = np.zeros(shape, np.int32)
futures = [
    stream.async_send_heap(ig.get_heap()),
    stream.async_send_heap(ig.get_end())
]
# Delete things to check that there are no refcounting bugs
del ig
del stream
trollius.get_event_loop().run_until_complete(trollius.wait(futures))
Example #4
0
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import spead2
import spead2.send
import spead2.send.trollius
import sys
import logging
import numpy as np
import trollius

logging.basicConfig(level=logging.INFO)

thread_pool = spead2.ThreadPool()
stream = spead2.send.trollius.UdpStream(
    thread_pool, "localhost", 8888, spead2.send.StreamConfig(rate=1e7))
del thread_pool  # Make sure this doesn't crash anything

shape = (40, 50)
ig = spead2.send.ItemGroup(flavour=spead2.Flavour(4, 64, 48, spead2.BUG_COMPAT_PYSPEAD_0_5_2))
item = ig.add_item(0x1234, 'foo', 'a foo item', shape=shape, dtype=np.int32)
item.value = np.zeros(shape, np.int32)
coros = [
    stream.async_send_heap(ig.get_heap()),
    stream.async_send_heap(ig.get_end())
]
# Delete things to check that there are no refcounting bugs
del ig
del stream
trollius.get_event_loop().run_until_complete(trollius.wait(coros))
Example #5
0
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import spead2
import spead2.send
import spead2.send.trollius
import logging
import numpy as np
import trollius

logging.basicConfig(level=logging.INFO)

thread_pool = spead2.ThreadPool()
stream = spead2.send.trollius.UdpStream(
    thread_pool, "127.0.0.1", 8888, spead2.send.StreamConfig(rate=1e7))
del thread_pool  # Make sure this doesn't crash anything

shape = (40, 50)
ig = spead2.send.ItemGroup(flavour=spead2.Flavour(4, 64, 48, spead2.BUG_COMPAT_PYSPEAD_0_5_2))
item = ig.add_item(0x1234, 'foo', 'a foo item', shape=shape, dtype=np.int32)
item.value = np.zeros(shape, np.int32)
futures = [
    stream.async_send_heap(ig.get_heap()),
    stream.async_send_heap(ig.get_end())
]
# Delete things to check that there are no refcounting bugs
del ig
del stream
trollius.get_event_loop().run_until_complete(trollius.wait(futures))