Python multiprocessing.connection.Pipe() Examples
The following are 17
code examples of multiprocessing.connection.Pipe().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
multiprocessing.connection
, or try the search function
.
Example #1
Source File: queues.py From loky with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #2
Source File: __init__.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def Pipe(duplex=True): ''' Returns two connection object connected by a pipe ''' from multiprocessing.connection import Pipe return Pipe(duplex)
Example #3
Source File: managers.py From unity-python with MIT License | 5 votes |
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 )
Example #4
Source File: __init__.py From unity-python with MIT License | 5 votes |
def Pipe(duplex=True): ''' Returns two connection object connected by a pipe ''' from multiprocessing.connection import Pipe return Pipe(duplex)
Example #5
Source File: managers.py From PokemonGo-DesktopMap with MIT License | 5 votes |
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 )
Example #6
Source File: __init__.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def Pipe(duplex=True): ''' Returns two connection object connected by a pipe ''' from multiprocessing.connection import Pipe return Pipe(duplex)
Example #7
Source File: TestSDRPlay.py From urh with GNU General Public License v3.0 | 5 votes |
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()
Example #8
Source File: managers.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
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 )
Example #9
Source File: __init__.py From ironpython2 with Apache License 2.0 | 5 votes |
def Pipe(duplex=True): ''' Returns two connection object connected by a pipe ''' from multiprocessing.connection import Pipe return Pipe(duplex)
Example #10
Source File: queues.py From loky with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, maxsize=0, reducers=None, ctx=None): if sys.version_info[:2] >= (3, 4): super().__init__(maxsize=maxsize, ctx=ctx) else: if maxsize <= 0: # Can raise ImportError (see issues #3770 and #23400) maxsize = SEM_VALUE_MAX if ctx is None: ctx = get_context() self._maxsize = maxsize self._reader, self._writer = connection.Pipe(duplex=False) self._rlock = ctx.Lock() self._opid = os.getpid() if sys.platform == 'win32': self._wlock = None else: self._wlock = ctx.Lock() self._sem = ctx.BoundedSemaphore(maxsize) # For use by concurrent.futures self._ignore_epipe = False self._after_fork() if sys.platform != 'win32': util.register_after_fork(self, Queue._after_fork) self._reducers = reducers # Use custom queue set/get state to be able to reduce the custom reducers
Example #11
Source File: managers.py From oss-ftp with MIT License | 5 votes |
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 )
Example #12
Source File: __init__.py From oss-ftp with MIT License | 5 votes |
def Pipe(duplex=True): ''' Returns two connection object connected by a pipe ''' from multiprocessing.connection import Pipe return Pipe(duplex)
Example #13
Source File: managers.py From BinderFilter with MIT License | 5 votes |
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 )
Example #14
Source File: __init__.py From BinderFilter with MIT License | 5 votes |
def Pipe(duplex=True): ''' Returns two connection object connected by a pipe ''' from multiprocessing.connection import Pipe return Pipe(duplex)
Example #15
Source File: managers.py From ironpython2 with Apache License 2.0 | 5 votes |
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 )
Example #16
Source File: TestUSRP.py From urh with GNU General Public License v3.0 | 4 votes |
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)
Example #17
Source File: TestBladeRF.py From urh with GNU General Public License v3.0 | 4 votes |
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()