Capture output coming from C and C++ libraries
- Lingua principale
- Python
- Stelle
- 734
- Fork
- 412
- Merge medio
- 1g 5h
- PR unite (30g)
- 8
Descrizione
Hi,
thanks for this excellent Kernel!
This is already a known behaviour: the output that is printed on screen by C/C++ libraries is not captured in the notebook: this can happen with ctypes or with Python bindings for C++ functions.
It would be terrific to have this output both captured and correctly interleaved with the output coming from Python and then printed "progressively" in the notebook.
For example, this loop could print every .5 secs a line from the Python and C world, interleaved:
> from ctypes import *
> libc = CDLL("libc.dylib")
> import time
> for i in xrange(10):
> print "This is Python"
> libc.printf("This is C\n")
> time.sleep(.5)
At CERN we solved this issue for the [ROOT Kernel](https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages) in a custom way. For Python, we converged on a [partial solution](https://github.com/root-mirror/root/blob/master/bindings/pyroot/JupyROOT/handlers.py), which allows to correctly interleave the outputs but not to print them "live" in an asynchronous way.
I wonder if a general solution to this rather common issue, at least in HEP, could be envisaged, e.g. a "baby sitting process" capturing the output.
Cheers,
Danilo
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
The issue names no ipykernel file or test; start with the ctypes example and the linked ROOT handlers.py to understand its partial interleaving approach. Investigate how a general solution could capture C/C++ output, interleave it with Python output, and emit it progressively, then define tests for the example and asynchronous behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, cpp, python
- Ambito
- backend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100