回答編集履歴

1

追記

2018/12/28 11:04

投稿

hayataka2049
hayataka2049

スコア30933

test CHANGED
@@ -11,3 +11,55 @@
11
11
 
12
12
 
13
13
  引数の与え方などは互換性があるので、multiprocessing.Processをthreading.Threadに置き換えるだけで動くはずです。
14
+
15
+
16
+
17
+ ### 追記
18
+
19
+ 効果があるかどうかわかりませんが、メインループが始まる前にforkしておくと行けるかもしれません。
20
+
21
+
22
+
23
+ ```python
24
+
25
+ # 略
26
+
27
+ from multiprocessing import Pool
28
+
29
+
30
+
31
+ # 略
32
+
33
+ class TestScreen(Screen):
34
+
35
+ def on_enter(self):
36
+
37
+ pass
38
+
39
+
40
+
41
+ def start_mp(self):
42
+
43
+ p.apply(count_time, args=[10])
44
+
45
+ print("end")
46
+
47
+
48
+
49
+ def stop_time(self):
50
+
51
+ p.terminate()
52
+
53
+ print(datetime.now())
54
+
55
+
56
+
57
+ if __name__ == '__main__':
58
+
59
+ p = Pool(1)
60
+
61
+ Test().run()
62
+
63
+
64
+
65
+ ```