回答編集履歴
1
追記
answer
CHANGED
@@ -4,4 +4,30 @@
|
|
4
4
|
|
5
5
|
https://docs.python.jp/3/library/threading.html#threading.Thread
|
6
6
|
|
7
|
-
引数の与え方などは互換性があるので、multiprocessing.Processをthreading.Threadに置き換えるだけで動くはずです。
|
7
|
+
引数の与え方などは互換性があるので、multiprocessing.Processをthreading.Threadに置き換えるだけで動くはずです。
|
8
|
+
|
9
|
+
### 追記
|
10
|
+
効果があるかどうかわかりませんが、メインループが始まる前にforkしておくと行けるかもしれません。
|
11
|
+
|
12
|
+
```python
|
13
|
+
# 略
|
14
|
+
from multiprocessing import Pool
|
15
|
+
|
16
|
+
# 略
|
17
|
+
class TestScreen(Screen):
|
18
|
+
def on_enter(self):
|
19
|
+
pass
|
20
|
+
|
21
|
+
def start_mp(self):
|
22
|
+
p.apply(count_time, args=[10])
|
23
|
+
print("end")
|
24
|
+
|
25
|
+
def stop_time(self):
|
26
|
+
p.terminate()
|
27
|
+
print(datetime.now())
|
28
|
+
|
29
|
+
if __name__ == '__main__':
|
30
|
+
p = Pool(1)
|
31
|
+
Test().run()
|
32
|
+
|
33
|
+
```
|