gil-holding sleep with cython.inline
(t)
| 18 | from cython import inline |
| 19 | |
| 20 | def gilsleep(t): |
| 21 | """gil-holding sleep with cython.inline""" |
| 22 | code = '\n'.join([ |
| 23 | 'from posix cimport unistd', |
| 24 | 'unistd.sleep(t)', |
| 25 | ]) |
| 26 | while True: |
| 27 | inline(code, quiet=True, t=t) |
| 28 | print(time.time()) |
| 29 | sys.stdout.flush() # this is important |
| 30 | |
| 31 | gilsleep(5) |