 (defun ycmd--teardown ()
   "Teardown ycmd in current buffer."
   (ycmd--kill-timer ycmd--notification-timer)
-  (setq ycmd--last-status-change 'unparsed)
-  (setq ycmd--file-already-parsing-exception nil))
+  (setq ycmd--last-status-change 'unparsed))
 
 (defun ycmd--global-teardown ()
   "Teardown ycmd in all buffers."

                            `((filepath . ,conf-file))))))
    (ycmd-notify-file-ready-to-parse)))

(defun ycmd--handle-runtime-exception (results)
  "Handle runtime exceptions in RESULTS."
  (let* ((exception (assoc-default 'exception results))
         (exception-type (assoc-default 'TYPE exception))
         (message (assoc-default 'message results)))
    (cond ((and (string-equal exception-type "RuntimeError")
                (string-equal message "File already being parsed."))
           (setq ycmd--file-already-parsing-exception t)))))

(defun ycmd--handle-notify-response (results)
  "If RESULTS is a vector or nil, the response is an acual parse result.
Otherwise the response is probably an exception."
  (if (or (not results)
          (vectorp results))
      (run-hook-with-args 'ycmd-file-parse-result-hook results)
    (when (assoc 'exception results)
      (ycmd--handle-exception
       results #'ycmd--handle-runtime-exception))))

(defvar-local ycmd--file-already-parsing-exception nil)
(defun ycmd--parsing-buffer-finished-p ()
  "Return t if parsing has finished."
  (if ycmd--file-already-parsing-exception
      (setq ycmd--file-already-parsing-exception nil)
    t))

(defun ycmd-notify-file-ready-to-parse ()
  "Send a notification to ycmd that the buffer is ready to be parsed.

           (content (cons '("event_name" . "FileReadyToParse")
                          (ycmd--standard-content-with-extras
                           buff extra-content))))
      (deferred:$
        ;; try
        (deferred:$
          ;; Record that the buffer is being parsed
          (ycmd--report-status 'parsing)

          ;; Make the request.
          (ycmd--request "/event_notification"
                         content
