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

Method exec

flow-plugins/src/image_server.rs:126–147  ·  view source on GitHub ↗
(&mut self, _: &Context)

Source from the content-addressed store, hash-verified

124 async fn initialize(&mut self, _: ResourceCollection) {}
125 async fn finalize(&mut self) {}
126 async fn exec(&mut self, _: &Context) -> Result<()> {
127 let state = State::new(self.ty, std::mem::take(&mut self.out));
128 let mapping = state.mapping.clone();
129 let inp = std::mem::take(&mut self.inp);
130
131 let (spec, filter) = openapi::spec().build(move || analyze(state));
132
133 join! {
134 serve(filter.or(openapi_docs(spec))).run(([0, 0, 0, 0], self.port)),
135 async move {
136 while let Ok(mut msg) = inp.recv::<PyObject>().await {
137 let id = msg.info().partial_id.expect("partial_id required by image_server");
138 let msg = msg.unpack();
139 let mut mapping = mapping.lock().await;
140 if let Some(sender) = mapping.remove(&id) {
141 sender.send(msg).ok();
142 }
143 }
144 }
145 };
146 Ok(())
147 }
148}
149
150node_register!("ImageServer", ImageServer);

Callers

nothing calls this directly

Calls 3

analyzeFunction · 0.70
cloneMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected