Skip to content

Commit 0868405

Browse files
committed
more doc
1 parent e8cd5e8 commit 0868405

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/random.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
//! let random_number = Python::with_gil(|py| -> PyResult<_> {
1818
//! let mut bitgen = default_bit_gen(py)?.lock()?;
1919
//! // use bitgen without holding the GIL
20-
//! Ok(py.allow_threads(|| bitgen.next_uint64()))
20+
//! let r = py.allow_threads(|| bitgen.next_uint64())?;
21+
//! // release the lock manually while holding the GIL again
22+
//! bitgen.release(py)?;
23+
//! Ok(r)
2124
//! })?;
2225
//! # Ok::<(), PyErr>(())
2326
//! ```
@@ -40,6 +43,7 @@
4043
//! if bitgen.random_ratio(1, 1_000_000) {
4144
//! println!("a sure thing");
4245
//! }
46+
//! bitgen.release(py)?;
4347
//! Ok(())
4448
//! })?;
4549
//! # Ok::<(), PyErr>(())

0 commit comments

Comments
 (0)