Пример #1
0
 def run(self):
     while 1:
         try:
             with self.lock:
                 if self.stop_server:
                     break
             self.server.handle_request()
         except KeyboardInterrupt:
             break
     print "\nServer shutting down..."
     driveboard.close()
Пример #2
0
 def run(self):
     while 1:
         try:
             with self.lock:
                 if self.stop_server:
                     break
             self.server.handle_request()
         except KeyboardInterrupt:
             break
     print "\nServer shutting down..."
     driveboard.close()
Пример #3
0
# wait for a connection
print("waiting for a connection")
connection, client_address = s.accept()
print(client_address)

try:
    # show who connected to us
    print("connection from {}".format(client_address))

    # receive the data in small chunks and print it
    while True:
        data = connection.recv(1024)
        if data:
            # output received data
            translation = data.decode("utf-8")
            translation = eval(translation)
            # move(translation)
            print(translation)
            control_move(translation)

        else:
            # no more data --quit the loop
            print("no more data")
            break
finally:
    # clean up the connection
    connection.close()

driveboard.close()