Commits

Alexander Schremmer  committed f8f4c75

Handle Ellipsis (errornous) responses correctly. Fixes #23. Also print stack of the frames in crash().

  • Participants
  • Parent commits 10291b5

Comments (0)

Files changed (2)

File domination/gameengine.py

         except:
             self.owner.request_queue.append(DebugRequest(sys.exc_info()))
         self.state = ENDED
+        self.waiting_for = None
         self.increment_seqno()
 
     def increment_seqno(self):

File domination/main.py

 import random
 import pickle
 import optparse
+import traceback
 
 from flask import Flask, render_template, session, redirect, url_for, \
         request, abort, jsonify
         if request.method == 'POST':
             cv = player.response_condition
             cv.acquire()
+            player.info_queue = []
             try:
                 req = player.request_queue[0]
                 assert hash(req) == int(request.form["req_id"])
                 if response is not Ellipsis:
                     player.response.append(response)
                     player.request_queue.pop(0)
-                    player.info_queue = []
                     cv.notify()
             finally:
                 cv.release()
-            cv = game_runner.seqno_condition
-            cv.acquire()
-            while game_runner.seqno <= req.seqno:
-                cv.wait()
-            cv.release()
+            if response is not Ellipsis:
+                cv = game_runner.seqno_condition
+                cv.acquire()
+                while game_runner.seqno <= req.seqno:
+                    cv.wait()
+                cv.release()
         req = None
         if player.request_queue:
             req = player.request_queue[0]
     if options.debug:
         @app.route("/crash")
         def crash():
+            for frame in sys._current_frames().values():
+                traceback.print_stack(frame)
+                print "\n"
             1/0
         app.secret_key = "insecure"