@@ -8,9 +8,9 @@ macro_rules! py_unary_func {
8
8
where
9
9
T : for <' p> $trait<' p>,
10
10
{
11
- let py = $crate:: Python :: assume_gil_acquired( ) ;
11
+ let pool = $crate:: GILPool :: new( ) ;
12
+ let py = pool. py( ) ;
12
13
$crate:: run_callback( py, || {
13
- let _pool = $crate:: GILPool :: new( py) ;
14
14
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( slf) ;
15
15
$crate:: callback:: convert( py, $call!( slf, $f) $( . map( $conv) ) ?)
16
16
} )
@@ -34,9 +34,9 @@ macro_rules! py_unary_refmut_func {
34
34
where
35
35
T : for <' p> $trait<' p>,
36
36
{
37
- let py = $crate:: Python :: assume_gil_acquired( ) ;
37
+ let pool = $crate:: GILPool :: new( ) ;
38
+ let py = pool. py( ) ;
38
39
$crate:: run_callback( py, || {
39
- let _pool = $crate:: GILPool :: new( py) ;
40
40
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( slf) ;
41
41
let res = $class:: $f( slf. borrow_mut( ) ) . into( ) ;
42
42
$crate:: callback:: convert( py, res $( . map( $conv) ) ?)
@@ -69,9 +69,9 @@ macro_rules! py_binary_func {
69
69
T : for <' p> $trait<' p>,
70
70
{
71
71
use $crate:: ObjectProtocol ;
72
- let py = $crate:: Python :: assume_gil_acquired( ) ;
72
+ let pool = $crate:: GILPool :: new( ) ;
73
+ let py = pool. py( ) ;
73
74
$crate:: run_callback( py, || {
74
- let _pool = $crate:: GILPool :: new( py) ;
75
75
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( slf) ;
76
76
let arg = py. from_borrowed_ptr:: <$crate:: PyAny >( arg) ;
77
77
$crate:: callback:: convert( py, $call!( slf, $f, arg) $( . map( $conv) ) ?)
@@ -99,9 +99,9 @@ macro_rules! py_binary_num_func {
99
99
T : for <' p> $trait<' p>,
100
100
{
101
101
use $crate:: ObjectProtocol ;
102
- let py = $crate:: Python :: assume_gil_acquired( ) ;
102
+ let pool = $crate:: GILPool :: new( ) ;
103
+ let py = pool. py( ) ;
103
104
$crate:: run_callback( py, || {
104
- let _pool = $crate:: GILPool :: new( py) ;
105
105
let lhs = py. from_borrowed_ptr:: <$crate:: PyAny >( lhs) ;
106
106
let rhs = py. from_borrowed_ptr:: <$crate:: PyAny >( rhs) ;
107
107
@@ -125,9 +125,9 @@ macro_rules! py_binary_reverse_num_func {
125
125
T : for <' p> $trait<' p>,
126
126
{
127
127
use $crate:: ObjectProtocol ;
128
- let py = $crate:: Python :: assume_gil_acquired( ) ;
128
+ let pool = $crate:: GILPool :: new( ) ;
129
+ let py = pool. py( ) ;
129
130
$crate:: run_callback( py, || {
130
- let _pool = $crate:: GILPool :: new( py) ;
131
131
// Swap lhs <-> rhs
132
132
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( rhs) ;
133
133
let arg = py. from_borrowed_ptr:: <$crate:: PyAny >( lhs) ;
@@ -155,9 +155,9 @@ macro_rules! py_binary_self_func {
155
155
{
156
156
use $crate:: ObjectProtocol ;
157
157
158
- let py = $crate:: Python :: assume_gil_acquired( ) ;
158
+ let pool = $crate:: GILPool :: new( ) ;
159
+ let py = pool. py( ) ;
159
160
$crate:: run_callback( py, || {
160
- let _pool = $crate:: GILPool :: new( py) ;
161
161
let slf_ = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( slf) ;
162
162
let arg = py. from_borrowed_ptr:: <$crate:: PyAny >( arg) ;
163
163
call_mut!( slf_, $f, arg) ?;
@@ -184,9 +184,9 @@ macro_rules! py_ssizearg_func {
184
184
where
185
185
T : for <' p> $trait<' p>,
186
186
{
187
- let py = $crate:: Python :: assume_gil_acquired( ) ;
187
+ let pool = $crate:: GILPool :: new( ) ;
188
+ let py = pool. py( ) ;
188
189
$crate:: run_callback( py, || {
189
- let _pool = $crate:: GILPool :: new( py) ;
190
190
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( slf) ;
191
191
$crate:: callback:: convert( py, $call!( slf, $f; arg. into( ) ) )
192
192
} )
@@ -209,9 +209,9 @@ macro_rules! py_ternary_func {
209
209
{
210
210
use $crate:: ObjectProtocol ;
211
211
212
- let py = $crate:: Python :: assume_gil_acquired( ) ;
212
+ let pool = $crate:: GILPool :: new( ) ;
213
+ let py = pool. py( ) ;
213
214
$crate:: run_callback( py, || {
214
- let _pool = $crate:: GILPool :: new( py) ;
215
215
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( slf) ;
216
216
let arg1 = py
217
217
. from_borrowed_ptr:: <$crate:: types:: PyAny >( arg1)
@@ -245,9 +245,9 @@ macro_rules! py_ternary_num_func {
245
245
{
246
246
use $crate:: ObjectProtocol ;
247
247
248
- let py = $crate:: Python :: assume_gil_acquired( ) ;
248
+ let pool = $crate:: GILPool :: new( ) ;
249
+ let py = pool. py( ) ;
249
250
$crate:: run_callback( py, || {
250
- let _pool = $crate:: GILPool :: new( py) ;
251
251
let arg1 = py
252
252
. from_borrowed_ptr:: <$crate:: types:: PyAny >( arg1)
253
253
. extract( ) ?;
@@ -280,9 +280,9 @@ macro_rules! py_ternary_reverse_num_func {
280
280
T : for <' p> $trait<' p>,
281
281
{
282
282
use $crate:: ObjectProtocol ;
283
- let py = $crate:: Python :: assume_gil_acquired( ) ;
283
+ let pool = $crate:: GILPool :: new( ) ;
284
+ let py = pool. py( ) ;
284
285
$crate:: run_callback( py, || {
285
- let _pool = $crate:: GILPool :: new( py) ;
286
286
// Swap lhs <-> rhs
287
287
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( arg2) ;
288
288
let slf = slf. try_borrow( ) ?;
@@ -312,9 +312,9 @@ macro_rules! py_dummy_ternary_self_func {
312
312
{
313
313
use $crate:: ObjectProtocol ;
314
314
315
- let py = $crate:: Python :: assume_gil_acquired( ) ;
315
+ let pool = $crate:: GILPool :: new( ) ;
316
+ let py = pool. py( ) ;
316
317
$crate:: run_callback( py, || {
317
- let _pool = $crate:: GILPool :: new( py) ;
318
318
let slf_cell = py. from_borrowed_ptr:: <$crate:: PyCell <T >>( slf) ;
319
319
let arg1 = py. from_borrowed_ptr:: <$crate:: PyAny >( arg1) ;
320
320
call_mut!( slf_cell, $f, arg1) ?;
@@ -338,9 +338,9 @@ macro_rules! py_func_set {
338
338
{
339
339
use $crate:: ObjectProtocol ;
340
340
341
- let py = $crate:: Python :: assume_gil_acquired( ) ;
341
+ let pool = $crate:: GILPool :: new( ) ;
342
+ let py = pool. py( ) ;
342
343
$crate:: run_callback( py, || {
343
- let _pool = $crate:: GILPool :: new( py) ;
344
344
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <$generic>>( slf) ;
345
345
346
346
if value. is_null( ) {
@@ -374,10 +374,9 @@ macro_rules! py_func_del {
374
374
{
375
375
use $crate:: ObjectProtocol ;
376
376
377
- let py = $crate:: Python :: assume_gil_acquired( ) ;
377
+ let pool = $crate:: GILPool :: new( ) ;
378
+ let py = pool. py( ) ;
378
379
$crate:: run_callback( py, || {
379
- let _pool = $crate:: GILPool :: new( py) ;
380
-
381
380
if value. is_null( ) {
382
381
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <U >>( slf) ;
383
382
let name = py
@@ -408,9 +407,9 @@ macro_rules! py_func_set_del {
408
407
{
409
408
use $crate:: ObjectProtocol ;
410
409
411
- let py = $crate:: Python :: assume_gil_acquired( ) ;
410
+ let pool = $crate:: GILPool :: new( ) ;
411
+ let py = pool. py( ) ;
412
412
$crate:: run_callback( py, || {
413
- let _pool = $crate:: GILPool :: new( py) ;
414
413
let slf = py. from_borrowed_ptr:: <$crate:: PyCell <$generic>>( slf) ;
415
414
let name = py. from_borrowed_ptr:: <$crate:: PyAny >( name) ;
416
415
0 commit comments