(&self, val: PyObjectRef, vm: &VirtualMachine)
| 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( |
no test coverage detected