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

Method release

crates/stdlib/src/multiprocessing.rs:223–247  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

221
222 #[pymethod]
223 fn release(&self, vm: &VirtualMachine) -> PyResult<()> {
224 if self.kind == RECURSIVE_MUTEX {
225 if !ismine!(self) {
226 return Err(vm.new_exception_msg(
227 vm.ctx.exceptions.assertion_error.to_owned(),
228 "attempt to release recursive lock not owned by thread".into(),
229 ));
230 }
231 if self.count.load(Ordering::Acquire) > 1 {
232 self.count.fetch_sub(1, Ordering::Release);
233 return Ok(());
234 }
235 }
236
237 if unsafe { ReleaseSemaphore(self.handle.as_raw(), 1, core::ptr::null_mut()) } == 0 {
238 let err = unsafe { windows_sys::Win32::Foundation::GetLastError() };
239 if err == ERROR_TOO_MANY_POSTS {
240 return Err(vm.new_value_error("semaphore or lock released too many times"));
241 }
242 return Err(vm.new_last_os_error());
243 }
244
245 self.count.fetch_sub(1, Ordering::Release);
246 Ok(())
247 }
248
249 #[pymethod(name = "__enter__")]
250 fn enter(&self, vm: &VirtualMachine) -> PyResult<bool> {

Callers 1

__exit__Method · 0.45

Calls 9

os_errorFunction · 0.85
new_exception_msgMethod · 0.80
new_last_os_errorMethod · 0.80
ErrClass · 0.50
GetLastErrorFunction · 0.50
to_ownedMethod · 0.45
loadMethod · 0.45
as_rawMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected