Commits

Anonymous committed 3207767

timeout

Comments (0)

Files changed (1)

         It returns a Python data-structure, while the parse()
         function returns a JSON object
         """
+        while True:
+            try:
+                ch = self._server.read_nonblocking (2000, 1)
+            except pexpect.TIMEOUT:
+                break
+
+        # clean up anything leftover
+
         self._server.sendline(text)
         # How much time should we give the parser to parse it?
         # the idea here is that you increase the timeout as a 
         incoming = ""
         while True: 
             # Time left, read more data
-            ch = self._server.read_nonblocking (2000, max_expected_time)
-            freshlen = len(ch)
-            time.sleep (0.0001)
-            incoming = incoming + ch
-            if "\nNLP>" in incoming:
+            try:
+                ch = self._server.read_nonblocking (2000, 1)
+                freshlen = len(ch)
+                time.sleep (0.0001)
+                incoming = incoming + ch
+                if "\nNLP>" in incoming:
+                    break
+            except pexpect.TIMEOUT:
+                print "Timeout" 
+                if end_time - time.time() < 0:
+                    return {'error': "timed out after %f seconds" % max_expected_time, 
+                            'input': text,
+                            'output': incoming}
+                else:
+                    continue
+            except pexpect.EOF:
                 break
-            if end_time - time.time() < 0:
-                return {'error': "timed out after %f seconds" % max_expected_time, 
-                        'input': text,
-                        'output': incoming}
         results = parse_parser_results(incoming)
         return results
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.