MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / batch_recv

Method batch_recv

flow-rs/src/loader/python/channel.rs:47–67  ·  view source on GitHub ↗
(&self, py: Python, n: usize, dur: u64)

Source from the content-addressed store, hash-verified

45 }
46
47 fn batch_recv(&self, py: Python, n: usize, dur: u64) -> (Vec<PyObject>, bool) {
48 let convert = |envelope| {
49 Py::new(
50 py,
51 PyEnvelope {
52 imp: Some(envelope),
53 },
54 )
55 .unwrap()
56 .to_object(py)
57 };
58 match with_context(py, || {
59 wait(
60 self.imp
61 .batch_recv::<PyObject>(n, Duration::from_millis(dur)),
62 )
63 }) {
64 Ok(msg) => (msg.into_iter().map(convert).collect(), false),
65 Err(BatchRecvError::Closed(msg)) => (msg.into_iter().map(convert).collect(), true),
66 }
67 }
68}
69
70pub trait Owned2PyObject {

Callers

nothing calls this directly

Calls 2

with_contextFunction · 0.85
to_objectMethod · 0.80

Tested by

no test coverage detected