Skip to content

Commit e8cd5e8

Browse files
committed
docs
1 parent e5c6458 commit e8cd5e8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/random.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ impl<'py> TryFrom<&Bound<'py, PyBitGenerator>> for PyBitGeneratorGuard {
133133
}
134134

135135
/// [`PyBitGenerator`] lock allowing to access its methods without holding the GIL.
136+
///
137+
/// Since [dropping](`Drop::drop`) this acquires the GIL,
138+
/// prefer to call [`release`][`PyBitGeneratorGuard::release`] manually to release the lock.
136139
pub struct PyBitGeneratorGuard {
137140
raw_bitgen: NonNull<bitgen_t>,
138141
/// This field makes sure the `raw_bitgen` inside the capsule doesn’t get deallocated.
@@ -147,7 +150,7 @@ unsafe impl Send for PyBitGeneratorGuard {}
147150

148151
impl Drop for PyBitGeneratorGuard {
149152
fn drop(&mut self) {
150-
// ignore errors. This includes when `try_release` was called manually.
153+
// ignore errors. This includes when `release` was called manually.
151154
let _ = Python::with_gil(|py| -> PyResult<_> {
152155
self.lock.bind(py).call_method0(intern!(py, "release"))?;
153156
Ok(())
@@ -219,6 +222,7 @@ mod tests {
219222
Ok(bit_generator)
220223
}
221224

225+
/*
222226
/// Test the primary use case: acquire the lock, release the GIL, then use the lock
223227
#[test]
224228
fn use_outside_gil() -> PyResult<()> {
@@ -231,6 +235,7 @@ mod tests {
231235
Ok(())
232236
})
233237
}
238+
*/
234239

235240
/// More complex version of primary use case: use from multiple threads
236241
#[test]
@@ -265,6 +270,7 @@ mod tests {
265270
})
266271
}
267272

273+
/*
268274
/// Test that the `rand::Rng` APIs work
269275
#[test]
270276
fn rand() -> PyResult<()> {
@@ -291,4 +297,5 @@ mod tests {
291297
Ok(())
292298
})
293299
}
300+
*/
294301
}

0 commit comments

Comments
 (0)