gilsleep.ipynb
60 lines
| 1.4 KiB
| text/plain
|
TextLexer
MinRK
|
r5885 | { | |
"metadata": { | |||
"name": "gilsleep" | |||
Brian Granger
|
r9201 | }, | |
"nbformat": 3, | |||
"nbformat_minor": 0, | |||
MinRK
|
r5885 | "worksheets": [ | |
{ | |||
"cells": [ | |||
{ | |||
Brian Granger
|
r9201 | "cell_type": "markdown", | |
"metadata": {}, | |||
MinRK
|
r5885 | "source": [ | |
Brian Granger
|
r9201 | "Holding the GIL for too long could disrupt the heartbeat due to non-copying sends.\n", | |
"\n", | |||
"The following cell repeatedly calls a function that holds the GIL for five seconds.\n", | |||
"\n", | |||
MinRK
|
r5885 | "The heartbeat will fail after a few iterations prior to fixing Issue [#1260](https://github.com/ipython/ipython/issues/1260)." | |
] | |||
Brian Granger
|
r9201 | }, | |
MinRK
|
r5885 | { | |
Brian Granger
|
r9201 | "cell_type": "code", | |
"collapsed": false, | |||
MinRK
|
r5885 | "input": [ | |
Brian Granger
|
r9201 | "import sys\n", | |
"import time\n", | |||
"\n", | |||
"from cython import inline\n", | |||
"\n", | |||
"def gilsleep(t):\n", | |||
" \"\"\"gil-holding sleep with cython.inline\"\"\"\n", | |||
" code = '\\n'.join([\n", | |||
" 'from posix cimport unistd',\n", | |||
" 'unistd.sleep(t)',\n", | |||
" ])\n", | |||
" while True:\n", | |||
" inline(code, quiet=True, t=t)\n", | |||
" print time.time()\n", | |||
" sys.stdout.flush() # this is important\n", | |||
"\n", | |||
MinRK
|
r5885 | "gilsleep(5)" | |
Brian Granger
|
r9201 | ], | |
"language": "python", | |||
"metadata": {}, | |||
"outputs": [], | |||
MinRK
|
r5885 | "prompt_number": 1 | |
Brian Granger
|
r9201 | }, | |
MinRK
|
r5885 | { | |
Brian Granger
|
r9201 | "cell_type": "code", | |
"collapsed": true, | |||
"input": [], | |||
"language": "python", | |||
"metadata": {}, | |||
"outputs": [], | |||
MinRK
|
r5885 | "prompt_number": " " | |
} | |||
Brian Granger
|
r9201 | ], | |
"metadata": {} | |||
MinRK
|
r5885 | } | |
] | |||
} |