示例#1
0
print('sent ready to ': + worker1_ip)
worker2.send( {'message': 'ready'} )
print('sent ready to ': + worker2_ip)

lcd.setRGB(0,128,128) # green

time.sleep(2) #long enough to see it go green

#Step 3. Wait until receive a signal from both workers

waiting_flag1 = True
waiting_flag2 = True

while waiting_flag1 and waiting_flag2:
    if waiting_flag1:
        table1 = worker1.get_table()
        print('worker1 sent me: ' + str( table1 ))
        
        waiting_flag1 = table1 == [] #if still empty then keep flag True

    if waiting_flag2:
        table2 = worker2.get_table()
        print('worker2 sent me: ' + str( table2 ))
        flag2 = table2 == [] #if still empty then keep flag True

    time.sleep( .5 )

print( 'got them both' )

#Step 4. Buzz then quit
示例#2
0
from Comm import Comm
#import Server
import time


neighbor1_ip = Comm("192.168.0.105")
neighbor2_ip = Comm("192.168.0.100")


neighbor1_ip.send( {'message': 'fyi', 'value': "Test"} )

neighbor2_ip.send( {'message': 'fyi', 'value': "Test"} )

flag1 = True
flag2 = True

while flag1 and flag2:
    if flag1:
        table1 = neighbor1_ip.get_table()
        print('neighbor1 sent: ' + str( table1 ))
        flag1 = table1 == [] #if still empty then keep flag True

    if flag2:
        table2 = neighbor2_ip.get_table()
        print('neighbor2 sent: ' + str( table2 ))
        flag2 = table2 == [] #if still empty then keep flag True

    time.sleep( .5 )

print( 'got them both' )