File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -389,9 +389,12 @@ These transitions are accomplished using two function decorators:
389
389
inner = trio.lowlevel.enable_ki_protection(inner)
390
390
return inner()
391
391
392
- assert example(False) == False
393
- assert example(True) == True # once protected ...
394
- assert example(False) == True # ... always protected
392
+ async def amain():
393
+ assert example(False) == False
394
+ assert example(True) == True # once protected ...
395
+ assert example(False) == True # ... always protected
396
+
397
+ trio.run(amain)
395
398
396
399
If you really need conditional protection, you can achieve it by giving each
397
400
KI-protected instance of the closure its own code object::
@@ -404,9 +407,12 @@ These transitions are accomplished using two function decorators:
404
407
inner = trio.lowlevel.enable_ki_protection(inner)
405
408
return inner()
406
409
407
- assert example(False) == False
408
- assert example(True) == True
409
- assert example(False) == False
410
+ async def amain():
411
+ assert example(False) == False
412
+ assert example(True) == True
413
+ assert example(False) == False
414
+
415
+ trio.run(amain)
410
416
411
417
(This isn't done by default because it carries some memory overhead and reduces
412
418
the potential for specializing optimizations in recent versions of CPython.)
You can’t perform that action at this time.
0 commit comments