本文整理汇总了Python中Server.setupSocket方法的典型用法代码示例。如果您正苦于以下问题:Python Server.setupSocket方法的具体用法?Python Server.setupSocket怎么用?Python Server.setupSocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server.setupSocket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Server [as 别名]
# 或者: from Server import setupSocket [as 别名]
def main():
print_lock = Lock()
socket_lock = Lock()
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Server.setupSocket(print_lock, server_addr, server_socket)
rasp_serial = serial.Serial(
port='/dev/ttyACM0', # Linux
#port='COM8', # Windows
baudrate=9600,
)
settings.init()
threads = []
update_sensors_thread = Thread(
target=Server.update_sensors,
args=(print_lock, rasp_serial)
)
threads.append(update_sensors_thread)
update_sensors_thread.start()
update_cameras_thread = Thread(
target=Server.update_camera
)
threads.append(update_cameras_thread)
update_cameras_thread.start()
should_continue = True
while should_continue:
with print_lock:
print "Waiting for new client..."
client, addr = server_socket.accept()
thread = Thread(target=Server.run, args=(print_lock, client))
threads.append(thread)
thread.start()
with print_lock:
print "Joining threads."
for thread in threads:
thread.join()
with print_lock:
print "All threads closed."