File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -193,9 +193,9 @@ where
193
193
194
194
/// Attempt to initialize the Python and Rust event loops
195
195
///
196
- /// - Must be called before any other pyo3-asyncio functions
197
- /// - Calling `try_init` twice returns `Ok(())` and does nothing
198
- /// > In future versions this may return an `Err`
196
+ /// - Must be called before any other pyo3-asyncio functions.
197
+ /// - Calling `try_init` a second time returns `Ok(())` and does nothing.
198
+ /// > In future versions this may return an `Err`.
199
199
pub fn try_init ( py : Python ) -> PyResult < ( ) > {
200
200
EVENT_LOOP . get_or_try_init ( || -> PyResult < PyObject > {
201
201
let asyncio = py. import ( "asyncio" ) ?;
Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ fn start_current_thread() {
77
77
}
78
78
79
79
/// Initialize the Tokio Runtime with current-thread scheduler
80
+ ///
81
+ /// # Panics
82
+ /// This function will panic if called a second time. See [`init_current_thread_once`] if you want
83
+ /// to avoid this panic.
80
84
pub fn init_current_thread ( ) {
81
85
init ( current_thread ( ) ) ;
82
86
start_current_thread ( ) ;
@@ -95,22 +99,26 @@ fn multi_thread() -> Runtime {
95
99
}
96
100
97
101
/// Initialize the Tokio Runtime with the multi-thread scheduler
102
+ ///
103
+ /// # Panics
104
+ /// This function will panic if called a second time. See [`init_multi_thread_once`] if you want to
105
+ /// avoid this panic.
98
106
pub fn init_multi_thread ( ) {
99
107
init ( multi_thread ( ) ) ;
100
108
}
101
109
102
110
/// Ensure that the Tokio Runtime is initialized
103
111
///
104
112
/// If the runtime has not been initialized already, the multi-thread scheduler
105
- /// is used. Otherwise this function is a no-op.
113
+ /// is used. Calling this function a second time is a no-op.
106
114
pub fn init_multi_thread_once ( ) {
107
115
TOKIO_RUNTIME . get_or_init ( || multi_thread ( ) ) ;
108
116
}
109
117
110
118
/// Ensure that the Tokio Runtime is initialized
111
119
///
112
120
/// If the runtime has not been initialized already, the current-thread
113
- /// scheduler is used. Otherwise this function is a no-op
121
+ /// scheduler is used. Calling this function a second time is a no-op.
114
122
pub fn init_current_thread_once ( ) {
115
123
let mut initialized = false ;
116
124
TOKIO_RUNTIME . get_or_init ( || {
You can’t perform that action at this time.
0 commit comments