MCPcopy Index your code
hub / github.com/RustPython/RustPython / send

Method send

crates/vm/src/builtins/asyncgenerator.rs:309–338  ·  view source on GitHub ↗
(&self, val: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

307
308 #[pymethod]
309 fn send(&self, val: PyObjectRef, vm: &VirtualMachine) -> PyResult {
310 let val = match self.state.load() {
311 AwaitableState::Closed => {
312 return Err(
313 vm.new_runtime_error("cannot reuse already awaited __anext__()/asend()")
314 );
315 }
316 AwaitableState::Iter => val, // already running, all good
317 AwaitableState::Init => {
318 if self.ag.running_async.load() {
319 return Err(
320 vm.new_runtime_error("anext(): asynchronous generator is already running")
321 );
322 }
323 self.ag.running_async.store(true);
324 self.state.store(AwaitableState::Iter);
325 if vm.is_none(&val) {
326 self.value.clone()
327 } else {
328 val
329 }
330 }
331 };
332 let res = self.ag.inner.send(self.ag.as_object(), val, vm);
333 let res = PyAsyncGenWrappedValue::unbox(&self.ag, res, vm);
334 if res.is_err() {
335 self.set_closed();
336 }
337 res
338 }
339
340 #[pymethod]
341 fn throw(

Callers 1

nextMethod · 0.45

Calls 15

is_errMethod · 0.80
set_closedMethod · 0.80
new_stop_iterationMethod · 0.80
ignored_closeMethod · 0.80
yield_closeMethod · 0.80
into_async_pyresultMethod · 0.80
handle_resultMethod · 0.80
ErrClass · 0.50
loadMethod · 0.45
storeMethod · 0.45
is_noneMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected