some test about mutiprocessing

This commit is contained in:
沈瑗杰 2021-01-11 22:54:41 +08:00
parent ccf5099ba1
commit 3626d448ec
4 changed files with 45 additions and 6 deletions

View File

@ -3,7 +3,7 @@ writen by shenjackyuanjie
mail: 3695888@qq.com mail: 3695888@qq.com
""" """
from libs import Game_threads from libs.Game_threads import orbit_demo
import libs import libs
import pyglet import pyglet
import threading import threading

View File

@ -7,9 +7,7 @@ import libs
import pyglet import pyglet
import threading import threading
from threading import Thread import pyglet.app
from pyglet.app import run
from pyglet.window import Window from pyglet.window import Window
from pyglet.resource import image from pyglet.resource import image
@ -31,7 +29,7 @@ class RenderThread(threading.Thread, pyglet.window.Window):
# list # list
def start_game(self): def start_game(self):
run() pyglet.app.run()
return return
def setup(self): def setup(self):

View File

@ -32,4 +32,4 @@ f = libs.P_C.S_N_M(A,libs.P_C.S_N_M(B,libs.P_C.S_N_M(C, D)))
print("A * B * C * D = " , e) print("A * B * C * D = " , e)
print("A * B * C * D = " , f) print("A * B * C * D = " , f)
G = libs.render G = libs.render_thread

41
test_mutiproser.py Normal file
View File

@ -0,0 +1,41 @@
import multiprocessing as mp
import os, time
class Main():
def __init__(self, dev) -> None:
self.aaa = 1
self.ttt = False
self.dev = dev
def main(self):
while self.ttt:
print(time.time())
print(os.getpid())
time.sleep(0.5)
while not(self.dev.using):
self.dev.using = True
if self.dev.bget == True:
print("B 没拿到")
else:
print("B 拿到了")
self.dev.aget = True
self.dev.using = False
class render():
def __init__(self, dev) -> None:
self.bbb = 3
self.ggg = True
class Delivery():
def __init__(self) -> None:
self.using = False
self.dev1 = ""
self.aget = False
self.bget = False
if __name__ == "__main__":
dev = Delivery()