我们如何暂停和恢复' socketserver' ???
我一直在查看socketserver文档,但我找不到引用。 https://docs.python.org/3.4/library/socketserver.html。
我初始化了socketserver
server = socketserver.UDPServer((HOST, PORT), MyUDPHandler)
server_thread = Thread(target=server.serve_forever, args=())
server_thread.daemon = False
server_thread.start()
之后,我们得到输入"离线5"这意味着socketserver暂停5秒并恢复
if text.split()[0] == 'offline':
duration = text.split()[1]
server.pause() ## ??????? PAUSE
print('Sleeping')
time.sleep(int(duration))
server.resume() ## ???????? RESUME
print('Node got up')