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

Method exec

flow-plugins/src/bytes_server.rs:92–113  ·  view source on GitHub ↗
(&mut self, _: &Context)

Source from the content-addressed store, hash-verified

90 async fn initialize(&mut self, _: ResourceCollection) {}
91 async fn finalize(&mut self) {}
92 async fn exec(&mut self, _: &Context) -> Result<()> {
93 let state = State::new(std::mem::take(&mut self.out));
94 let mapping = state.mapping.clone();
95 let inp = std::mem::take(&mut self.inp);
96
97 let (spec, filter) = openapi::spec().build(move || analyze(state));
98
99 join! {
100 serve(filter.or(openapi_docs(spec))).run(([0, 0, 0, 0], self.port)),
101 async move {
102 while let Ok(mut msg) = inp.recv::<PyObject>().await {
103 let id = msg.info().partial_id.expect("partial_id required by bytes_server");
104 let msg = msg.unpack();
105 let mut mapping = mapping.lock().await;
106 if let Some(sender) = mapping.remove(&id) {
107 sender.send(msg).ok();
108 }
109 }
110 }
111 };
112 Ok(())
113 }
114}
115
116node_register!("BytesServer", BytesServer);

Callers

nothing calls this directly

Calls 3

analyzeFunction · 0.70
cloneMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected