Commit 637c35c
committed
Try to capture stdout and err going directly to 1/2 filedescriptor.
This try to fix a long standing issue that stdout and stderr going
directly to the filedescriptor are not shown in notebooks.
This is annoying when using wrappers around c-libraries, or calling
system commands as those will not be seen from within notebook.
Here we redirect and split the filedescriptor and watch those in threads
and redirect both to the original FD (terminal), and ZMQ (notebook).
Thus output sent to fd 1 & 2 will be shown BOTH in terminal that
launched the notebook server and in notebook themselves.
One of the concern is that now logs and errors internal to ipykernel may
appear in the notebook themselves, so may confuse user; though these
should be limited to error and debug; and we can workaround this by
setting the log handler to not be stdout/err.
This still seem like a big hack to me, and I don't like thread.
I did not manage to make reading the FD non-blocking; so this cannot be
put in the io-thread – at least I'm not sure how. So adds 2 extra
threads to the kernel.
This might need to be turn off by default for now until further testing.
Locally this seem to work with things like:
- os.system("echo HELLO WORLD")
- c-extensions writing directly to fd 1 and 2 (when properly flushed).
I have no clue how filedescriptor work on windows, so this only change
behavior on linux and mac.1 parent 7e85756 commit 637c35c
2 files changed
+73
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
288 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
289 | 327 | | |
290 | 328 | | |
291 | 329 | | |
| |||
297 | 335 | | |
298 | 336 | | |
299 | 337 | | |
300 | | - | |
301 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
302 | 344 | | |
303 | 345 | | |
304 | 346 | | |
| |||
312 | 354 | | |
313 | 355 | | |
314 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
315 | 363 | | |
316 | 364 | | |
317 | 365 | | |
318 | 366 | | |
319 | 367 | | |
320 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
321 | 382 | | |
322 | 383 | | |
323 | 384 | | |
324 | 385 | | |
325 | 386 | | |
326 | 387 | | |
327 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
328 | 395 | | |
329 | 396 | | |
330 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
828 | | - | |
829 | | - | |
830 | | - | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
831 | 831 | | |
832 | 832 | | |
833 | 833 | | |
| |||
0 commit comments