当前位置: 首页>>代码示例>>Python>>正文


Python connection.Pipe方法代码示例

本文整理汇总了Python中multiprocessing.connection.Pipe方法的典型用法代码示例。如果您正苦于以下问题:Python connection.Pipe方法的具体用法?Python connection.Pipe怎么用?Python connection.Pipe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.connection的用法示例。


在下文中一共展示了connection.Pipe方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Pipe [as 别名]
def __init__(self, reducers=None, ctx=None):
        if sys.version_info[:2] >= (3, 4):
            super().__init__(ctx=ctx)
        else:
            # Use the context to create the sync objects for python2.7/3.3
            if ctx is None:
                ctx = get_context()
            self._reader, self._writer = connection.Pipe(duplex=False)
            self._rlock = ctx.Lock()
            self._poll = self._reader.poll
            if sys.platform == 'win32':
                self._wlock = None
            else:
                self._wlock = ctx.Lock()

        # Add possiblity to use custom reducers
        self._reducers = reducers 
开发者ID:joblib,项目名称:loky,代码行数:19,代码来源:queues.py

示例2: Pipe

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Pipe [as 别名]
def Pipe(duplex=True):
    '''
    Returns two connection object connected by a pipe
    '''
    from multiprocessing.connection import Pipe
    return Pipe(duplex) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:__init__.py

示例3: start

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Pipe [as 别名]
def start(self, initializer=None, initargs=()):
        '''
        Spawn a server process for this manager object
        '''
        assert self._state.value == State.INITIAL

        if initializer is not None and not hasattr(initializer, '__call__'):
            raise TypeError('initializer must be a callable')

        # pipe over which we will retrieve address of server
        reader, writer = connection.Pipe(duplex=False)

        # spawn process which runs a server
        self._process = Process(
            target=type(self)._run_server,
            args=(self._registry, self._address, self._authkey,
                  self._serializer, writer, initializer, initargs),
            )
        ident = ':'.join(str(i) for i in self._process._identity)
        self._process.name = type(self).__name__  + '-' + ident
        self._process.start()

        # get address of server
        writer.close()
        self._address = reader.recv()
        reader.close()

        # register a finalizer
        self._state.value = State.STARTED
        self.shutdown = util.Finalize(
            self, type(self)._finalize_manager,
            args=(self._process, self._address, self._authkey,
                  self._state, self._Client),
            exitpriority=0
            ) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:37,代码来源:managers.py

示例4: test_c_wrapper

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Pipe [as 别名]
def test_c_wrapper(self):
        def pycallback(data):
            arr = np.asarray(data)
            #result = np.empty(len(arr) // 2, dtype=np.complex64)
            #result.real = (arr[::2] + 0.5) / 32767.5
            #result.imag = (arr[1::2] + 0.5) / 32767.5

        print(sdrplay.get_api_version())
        print(sdrplay.get_devices())
        print(sdrplay.set_device_index(0))

        parent_conn, child_conn = Pipe()
        p = Process(target=recv, args=(parent_conn,))
        p.daemon = True
        p.start()

        null_ptr = ctypes.POINTER(ctypes.c_voidp)()
        print("Init stream", sdrplay.init_stream(50, 2e6, 433.92e6, 2e6, 500, child_conn))

        time.sleep(2)
        print("settings sample rate")
        print("Set sample rate", sdrplay.set_sample_rate(2e6))

        time.sleep(1)
        p.terminate()
        p.join() 
开发者ID:jopohl,项目名称:urh,代码行数:28,代码来源:TestSDRPlay.py

示例5: test_cython_wrapper

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Pipe [as 别名]
def test_cython_wrapper(self):
        print(usrp.find_devices(""))

        usrp.set_tx(False)

        return_code = usrp.open("addr=192.168.10.2")
        print("open", return_code)

        usrp.setup_stream()
        print("Made rx_streame handler")

        print(usrp.get_device_representation())

        print("Set sample rate", usrp.set_sample_rate(2e6))
        print("Set freq", usrp.set_center_freq(433.92e6))
        print("Set bandwidth", usrp.set_bandwidth(1e6))
        print("Set gain", usrp.set_rf_gain(0.5))



        buffer = bytearray()

        num_samples = 32768 // 2

        usrp.start_stream(num_samples)
        parent_conn, child_conn = Pipe()

        for i in range(500):
            usrp.recv_stream(child_conn, num_samples)
            received_bytes = parent_conn.recv_bytes()
            #print(received_bytes)
            print(i)
            buffer.extend(received_bytes)
            #print(USRP.bytes_to_iq(received_bytes, len(received_bytes) // 8))

        f = open("/tmp/test.complex", "wb")
        f.write(buffer)
        f.close()

        usrp.destroy_stream()
        print("Freed rx streamer handler")

        return_code = usrp.close()
        print("close", return_code)


        #self.assertTrue(True) 
开发者ID:jopohl,项目名称:urh,代码行数:49,代码来源:TestUSRP.py

示例6: test_cython_wrapper

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Pipe [as 别名]
def test_cython_wrapper(self):
        serials = bladerf.get_device_list()
        print("Connected serials", serials)

        bladerf.open()

        bladerf.set_tx(True)
        bladerf.set_channel(0)
        print("set gain", bladerf.set_gain(20))
        print("set gain", bladerf.set_gain(21))

        bladerf.set_tx(False)
        bladerf.set_channel(1)
        print("Sample Rate", bladerf.get_sample_rate())
        print("Set sample rate to 2e6", bladerf.set_sample_rate(int(2e6)))
        print("sample rate", bladerf.get_sample_rate())
        print("Set sample rate to 40e6", bladerf.set_sample_rate(int(40e6)))
        print("sample rate", bladerf.get_sample_rate())
        print("Set sample rate to 200e6", bladerf.set_sample_rate(int(200e6)))
        print("sample rate", bladerf.get_sample_rate())

        bladerf.set_tx(True)
        bladerf.set_channel(1)
        print("Bandwidth", bladerf.get_bandwidth())
        print("Set Bandwidth to 2e6", bladerf.set_bandwidth(int(2e6)))
        print("Bandwidth", bladerf.get_bandwidth())

        bladerf.set_tx(False)
        bladerf.set_channel(0)
        print("Frequency", bladerf.get_center_freq())
        print("Set Frequency to 433.92e6", bladerf.set_center_freq(int(433.92e6)))
        print("Frequency", bladerf.get_center_freq())

        bladerf.prepare_sync()

        parent_conn, child_conn = Pipe()

        for i in range(3):
            bladerf.receive_sync(child_conn, 4096)
            data = parent_conn.recv_bytes()
            print(data)

        bladerf.close()

        bladerf.open()
        bladerf.set_tx(True)
        bladerf.set_channel(0)
        bladerf.prepare_sync()

        for i in range(10):
            print("Send", bladerf.send_sync(np.fromstring(data, dtype=np.int16)))
        bladerf.close() 
开发者ID:jopohl,项目名称:urh,代码行数:54,代码来源:TestBladeRF.py


注:本文中的multiprocessing.connection.Pipe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。