(zelf: PyRef<Self>, vm: &VirtualMachine)
| 1778 | |
| 1779 | #[pymethod] |
| 1780 | fn close(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult { |
| 1781 | // Don't hold the lock while calling Python code to avoid reentrant lock issues |
| 1782 | let raw = { |
| 1783 | let data = zelf.lock(vm)?; |
| 1784 | let raw = data.check_init(vm)?; |
| 1785 | if file_closed(raw, vm)? { |
| 1786 | return Ok(vm.ctx.none()); |
| 1787 | } |
| 1788 | raw.to_owned() |
| 1789 | }; |
| 1790 | if zelf.finalizing().load(Ordering::Relaxed) { |
| 1791 | // _dealloc_warn: delegate to raw._dealloc_warn(source) |
| 1792 | let _ = vm.call_method(&raw, "_dealloc_warn", (zelf.as_object().to_owned(),)); |
| 1793 | } |
| 1794 | // Set closing flag so that concurrent write() calls will fail |
| 1795 | zelf.closing().store(true, Ordering::Release); |
| 1796 | let flush_res = vm.call_method(zelf.as_object(), "flush", ()).map(drop); |
| 1797 | let close_res = vm.call_method(&raw, "close", ()); |
| 1798 | exception_chain(flush_res, close_res) |
| 1799 | } |
| 1800 | |
| 1801 | #[pymethod] |
| 1802 | fn readable(&self) -> bool { |
nothing calls this directly
no test coverage detected