A generator that releases the GIL when closed or dealloc'ed.
()
| 471 | N_THREADS = 2 |
| 472 | |
| 473 | def sleeper_gen(): |
| 474 | """A generator that releases the GIL when closed or dealloc'ed.""" |
| 475 | try: |
| 476 | yield |
| 477 | finally: |
| 478 | time.sleep(0.000001) |
| 479 | |
| 480 | class C(list): |
| 481 | # Appending to a list is atomic, which avoids the use of a lock. |