(
&self,
exc_type: PyObjectRef,
exc_val: OptionalArg,
exc_tb: OptionalArg,
vm: &VirtualMachine,
)
| 339 | |
| 340 | #[pymethod] |
| 341 | fn throw( |
| 342 | &self, |
| 343 | exc_type: PyObjectRef, |
| 344 | exc_val: OptionalArg, |
| 345 | exc_tb: OptionalArg, |
| 346 | vm: &VirtualMachine, |
| 347 | ) -> PyResult { |
| 348 | match self.state.load() { |
| 349 | AwaitableState::Closed => { |
| 350 | return Err( |
| 351 | vm.new_runtime_error("cannot reuse already awaited __anext__()/asend()") |
| 352 | ); |
| 353 | } |
| 354 | AwaitableState::Init => { |
| 355 | if self.ag.running_async.load() { |
| 356 | self.state.store(AwaitableState::Closed); |
| 357 | return Err( |
| 358 | vm.new_runtime_error("anext(): asynchronous generator is already running") |
| 359 | ); |
| 360 | } |
| 361 | self.ag.running_async.store(true); |
| 362 | self.state.store(AwaitableState::Iter); |
| 363 | } |
| 364 | AwaitableState::Iter => {} |
| 365 | } |
| 366 | |
| 367 | warn_deprecated_throw_signature(&exc_val, &exc_tb, vm)?; |
| 368 | let res = self.ag.inner.throw( |
| 369 | self.ag.as_object(), |
| 370 | exc_type, |
| 371 | exc_val.unwrap_or_none(vm), |
| 372 | exc_tb.unwrap_or_none(vm), |
| 373 | vm, |
| 374 | ); |
| 375 | let res = PyAsyncGenWrappedValue::unbox(&self.ag, res, vm); |
| 376 | if res.is_err() { |
| 377 | self.set_closed(); |
| 378 | } |
| 379 | res |
| 380 | } |
| 381 | |
| 382 | #[pymethod] |
| 383 | fn close(&self, vm: &VirtualMachine) -> PyResult<()> { |
no test coverage detected