Menu

#2 branch.py not working as intended

open
nobody
None
5
2012-02-14
2012-02-14
No

It seems that branch.py does not work as I would expect it. So I figured it worth mentioning and posting a "fix" here. The unpatched code will do the following:
* Every time a client connects, it will add a button to the monitor station labeled with the entire set of connected clients (i.e. "0", then "1", then "1 2", then "1 2 3")
* If you connect a client from a specific URL (i.e. http://XXX.XXX.XX.XX:8000/5\), it will skip the intervening integers in the label (i.e. "0", then "1", then "1 _ _ _ _ 5" if 5 logs on.). If you then connect with a lower integer, it will backfill the blanks.
* When you click on a button, it purports to run the session function on only the clients included in the label. However, it will pass the ENTIRE pool of connected clients, not just the subset labeled, to the session function for each client in the subset.

In this way, it effectively prevents the clients not in the subset from participating. HOWEVER, this causes complications because those connected clients are still passed to the session function as being part of the subject pool. So while those clients are not running their own thread, each other client "thinks" that they are. As a result, if you use the local "numbers" list as a list of participating clients, you are actually including connected clients that have been locked out. This makes a common procedure like having the monitor (client 0) thread block until a signal is received from each client in the list a dicey proposition. The client will wait for a signal to be sent from a non-participatory client, locking up the session.

Discussion

  • Michael LeGower

    Michael LeGower - 2012-02-14

    Patched branch.py file

     
  • Michael LeGower

    Michael LeGower - 2012-02-14

    To remedy this, replace lines 54-67 with the following:

    elif i in subset:
    put({"tag":"ping","pool":subset, "client":i})
    else:
    put({"tag":"ping","pool":None, "client":i})
    else:
    let("<h1 style='font-size:3000%%'>%s</h1>" % me)
    put({"tag":"login","client": me})
    msg = take({"tag":"ping","client":me})
    subset = msg["pool"]
    if subset:
    let("<h1 style='color:green; font-size:3000%%'>%s</h1>" % me)
    session(me,subset)
    else:
    let("<h1 style='color:red; font-size:3000%%'>X</h1>")

     

Log in to post a comment.