fix while stopper
This commit is contained in:
@@ -1,39 +1,36 @@
|
||||
from cmd_server import CmdServer, HandshakePayload, PixelKind
|
||||
from while_stopper import WhileStopper
|
||||
from while_stopper import INSTANCE as STOPPER
|
||||
import logging
|
||||
import signal
|
||||
|
||||
|
||||
def receive_data() -> None:
|
||||
logging.info('Data received')
|
||||
logging.info("Data received")
|
||||
|
||||
|
||||
def main():
|
||||
server = CmdServer()
|
||||
|
||||
print('Please launch BasaltPresenter now.')
|
||||
print('Then press Enter to continue...')
|
||||
print("Please launch BasaltPresenter now.")
|
||||
print("Then press Enter to continue...")
|
||||
input()
|
||||
|
||||
logging.info('Waiting BasaltPresenter...')
|
||||
logging.info("Waiting BasaltPresenter...")
|
||||
server.wait_handshake(HandshakePayload(PixelKind.GRAY_U8, 600, 600))
|
||||
|
||||
logging.info('Start to running.')
|
||||
stopper = WhileStopper()
|
||||
stopper.register()
|
||||
logging.info("Start to running.")
|
||||
STOPPER.register()
|
||||
while True:
|
||||
if server.tick(receive_data, stopper.is_stop_requested()):
|
||||
if server.tick(receive_data, STOPPER.is_stop_requested()):
|
||||
break
|
||||
stopper.unregister()
|
||||
STOPPER.unregister()
|
||||
|
||||
logging.info('Program stop.')
|
||||
|
||||
print('Press Enter to exit...')
|
||||
input()
|
||||
logging.info("Program stop.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='[%(asctime)s] [%(levelname)s] %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S')
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="[%(asctime)s] [%(levelname)s] %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user