subprocess stdout capture does not seem to work on Windows

オープン
#882 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

Issue の ProcessPoolExecutor の再現例から始め、Windows と Linux での挙動を比較してください。subprocess stdout のキャプチャについて説明している ipykernel 6.0.0 の changelog エントリを読み、関連するキャプチャ経路を追跡してください。完了条件は、Linux の挙動を壊すことなく、例の subprocess 出力が Windows で表示されることです。

索引モデルが issue の本文から書いたものです。

説明

ipykernel is capturing stdout from subprocesses since ipykernel 6.0.0 according to the changelog.

On Windows it does not seem like the output of subprocesses is correctly captured. Here is a snippet to reproduce:

This came up in https://github.com/scikit-learn/scikit-learn/issues/22849#issuecomment-1068947522.

from concurrent.futures import ProcessPoolExecutor

# write local module since on Windows you can not use interactively defined functions in ProcessPoolExecutor
with open('func.py', 'w') as f:
    f.write('def func(arg): print("from subprocess, arg:", arg)')

from func import func
    
executor = ProcessPoolExecutor(max_workers=2)
future = executor.submit(func, 1)
future.result()

On Linux (output from the subprocess is visible)
image

On Windows (no output from the subprocess):
image

Windows environment details
# packages in environment at C:\Users\lesteve\mambaforge\envs\test:
#
# Name                    Version                   Build  Channel
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0          py310he2412df_1    conda-forge
asttokens                 2.0.5              pyhd8ed1ab_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.10.0             pyha770c72_0    conda-forge
bleach                    4.1.0              pyhd8ed1ab_0    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2021.10.8            h5b45459_0    conda-forge
cffi                      1.15.0          py310hcbf9ad4_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
debugpy                   1.5.1           py310h8a704f9_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
executing                 0.8.3              pyhd8ed1ab_0    conda-forge
flit-core                 3.7.1              pyhd8ed1ab_0    conda-forge
icu                       68.2                 h0e60522_0    conda-forge
importlib-metadata        4.11.3          py310h5588dad_0    conda-forge
importlib_resources       5.4.0              pyhd8ed1ab_0    conda-forge
ipykernel                 6.9.2           py310hbbfc1a7_0    conda-forge
ipython                   8.1.1           py310h5588dad_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.5              pyhd8ed1ab_0    conda-forge
jedi                      0.18.1          py310h5588dad_0    conda-forge
jinja2                    3.0.3              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h8ffe710_0    conda-forge
jsonschema                4.4.0              pyhd8ed1ab_0    conda-forge
jupyter                   1.0.0           py310h5588dad_7    conda-forge
jupyter_client            7.1.2              pyhd8ed1ab_0    conda-forge
jupyter_console           6.4.3              pyhd8ed1ab_0    conda-forge
jupyter_core              4.9.2           py310h5588dad_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_widgets        1.0.2              pyhd8ed1ab_0    conda-forge
libclang                  11.1.0          default_h5c34c98_1    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libsodium                 1.0.18               h8d14728_1    conda-forge
libzlib                   1.2.11            h8ffe710_1013    conda-forge
markupsafe                2.1.1           py310he2412df_0    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mistune                   0.8.4           py310he2412df_1005    conda-forge
nbclient                  0.5.13             pyhd8ed1ab_0    conda-forge
nbconvert                 6.4.4           py310h5588dad_0    conda-forge
nbformat                  5.2.0              pyhd8ed1ab_0    conda-forge
nest-asyncio              1.5.4              pyhd8ed1ab_0    conda-forge
notebook                  6.4.10             pyha770c72_0    conda-forge
openssl                   1.1.1l               h8ffe710_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandoc                    2.17.1.1             h57928b3_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
prometheus_client         0.13.1             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.27             pyha770c72_0    conda-forge
prompt_toolkit            3.0.27               hd8ed1ab_0    conda-forge
psutil                    5.9.0           py310he2412df_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.11.2             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.7              pyhd8ed1ab_0    conda-forge
pyqt                      5.12.3          py310h5588dad_8    conda-forge
pyqt-impl                 5.12.3          py310h8a704f9_8    conda-forge
pyqt5-sip                 4.19.18         py310h8a704f9_8    conda-forge
pyqtchart                 5.12            py310h8a704f9_8    conda-forge
pyqtwebengine             5.12.1          py310h8a704f9_8    conda-forge
pyrsistent                0.18.1          py310he2412df_0    conda-forge
python                    3.10.2          h9a09f29_4_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.10                    2_cp310    conda-forge
pywin32                   303             py310he2412df_0    conda-forge
pywinpty                  2.0.5           py310h00ffb61_0    conda-forge
pyzmq                     22.3.0          py310h73ada01_1    conda-forge
qt                        5.12.9               h5909a2a_4    conda-forge
qtconsole                 5.2.2              pyhd8ed1ab_1    conda-forge
qtconsole-base            5.2.2              pyhd8ed1ab_1    conda-forge
qtpy                      2.0.1              pyhd8ed1ab_0    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                60.9.3          py310h5588dad_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sqlite                    3.37.1               h8ffe710_0    conda-forge
stack_data                0.2.0              pyhd8ed1ab_0    conda-forge
terminado                 0.13.3          py310h5588dad_0    conda-forge
testpath                  0.6.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
tornado                   6.1             py310he2412df_2    conda-forge
traitlets                 5.1.1              pyhd8ed1ab_0    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
vc                        14.2                 hb210afc_6    conda-forge
vs2015_runtime            14.29.30037          h902a5da_6    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
widgetsnbextension        3.5.2           py310h5588dad_1    conda-forge
winpty                    0.4.3                         4    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
zeromq                    4.3.4                h0e60522_1    conda-forge
zipp                      3.7.0              pyhd8ed1ab_1    conda-forge
zlib                      1.2.11            h8ffe710_1013    conda-forge

主要言語
Python
スター
734
フォーク
411
平均マージ
1日 2時間
マージ済み PR(30日)
9

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ipython/ipykernel のほかの issue

ipython/ipykernel の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。