質問編集履歴

2

加筆

2022/12/18 08:32

投稿

tthk
tthk

スコア11

test CHANGED
File without changes
test CHANGED
@@ -4,11 +4,27 @@
4
4
 
5
5
  ### 実現したいこと
6
6
 
7
+ プログレスバーをプロセス分出力させたいです。例えば、以下のコードの場合、num_process分プログレスバーを出力させたいです。
8
+
9
+ 例:
10
+ 0: 90%████████████████████ | 9/10 [09:00<01:00, 60.00s/it]
11
+ 1: 90%████████████████████ | 9/10 [09:00<01:00, 60.00s/it]
12
+ 2: 90%████████████████████ | 9/10 [09:00<01:00, 60.00s/it]
13
+
7
- プログレスバーをプロセス分出力させたいです。
14
+ このように、それぞれのプロセスでの進捗状況が見られるようにしたいです。
8
15
 
9
16
  ### 発生している問題
17
+ 1つのプログレスバーが上書きされて出力される。
10
18
 
19
+ 例えば、以下のコードの場合で、1個目のプロセスがfor文の中の任意の処理を一回終えると次のような出力がターミナル上にでます。
20
+
21
+ 0: 10%█                 | 1/10 [01:00<09:00, 60.00s/it]
22
+
23
+ 次に、2個目のプロセスがfor文の任意の処理を一回終えますが、この進捗が出力される場合、上記のプログレスバーがターミナル上から消去され、次のような出力がターミナル上に出ます。
24
+
25
+ 1: 10%█                 | 1/10 [01:00<09:00, 60.00s/it]
26
+
11
- 1つのプログレスバーが上書きされて出力される
27
+ したがって、見かけ上では1つのプログレスバーが上書きされるようになっしまいます
12
28
 
13
29
  ### 該当のソースコード
14
30
 
@@ -17,13 +33,13 @@
17
33
  import concurrent.futures
18
34
 
19
35
  def f(idx):
20
- n = 100
36
+ n = 10
21
37
  for i in tqdm(range(n), desc=str(idx)):
22
38
  # 任意の処理
23
39
  return
24
40
 
25
41
  if __name__ == '__main__':
26
- num_process = 10
42
+ num_process = 3
27
43
  executor = concurrent.futures.ProcessPoolExector(max_workers=num_process)
28
44
  for idx in range(num_process):
29
45
  executor.submit(f, idx)

1

誤字

2022/12/18 07:24

投稿

tthk
tthk

スコア11

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
  # 任意の処理
23
23
  return
24
24
 
25
- if __name__ t== '__main__':
25
+ if __name__ == '__main__':
26
26
  num_process = 10
27
27
  executor = concurrent.futures.ProcessPoolExector(max_workers=num_process)
28
28
  for idx in range(num_process):