Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip warning messages when running vernacular queries #12

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/coq_serapy/serapi_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
NoSuchGoalError)
from .contexts import ProofContext, Obligation, SexpObligation
from .coq_util import raise_, parsePPSubgoal, setup_opam_env, get_module_from_filename
from .util import (eprint, parseSexpOneLevel, unwrap, progn)
from .util import (eprint, parseSexpOneLevel, unwrap, progn, kill_process_and_children)
if TYPE_CHECKING:
from sexpdata import Sexp

Expand Down Expand Up @@ -168,8 +168,9 @@ def getProofContext(self) -> Optional[ProofContext]:

def close(self) -> None:
assert self._proc.stdout
self._proc.terminate()
self._proc.kill()
kill_process_and_children(self._proc)
# self._proc.terminate()
# self._proc.kill()
self.__sema.release()
def isInProof(self) -> bool:
return self.proof_context is not None
Expand Down Expand Up @@ -297,7 +298,7 @@ def get_all_sexp_goals(self) -> List[SexpObligation]:
return []
def _isFeedbackMessage(self, msg: str) -> bool:
# if self.coq_minor_version() > 12:
return isFeedbackMessage(msg)
return isFeedbackMessage(msg) or isFeedbackWarningMessage(msg) or isFeedbackMessageOld(msg)
# return isFeedbackMessageOld(msg)
def _flush_queue(self) -> None:
while not self.message_queue.empty():
Expand Down Expand Up @@ -770,6 +771,15 @@ def isFeedbackMessage(msg: 'Sexp') -> bool:
lambda *args: True,
_, lambda *args: False)

def isFeedbackWarningMessage(msg: 'Sexp') -> bool:
return match(normalizeMessage(msg, depth=6),
["Feedback", [["doc_id", int], ["span_id", int],
["route", int],
["contents", ["Message", ["level", "Warning"],
["loc", []], TAIL]]]],
lambda *args: True,
_, lambda *args: False)

def isProgressMessage(msg: 'Sexp') -> bool:
return match(normalizeMessage(msg),
["Feedback", [["doc_id", int], ["span_id", int],
Expand Down
7 changes: 7 additions & 0 deletions src/coq_serapy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
import sys

from typing import (Optional, Tuple, TypeVar, Union, List, Pattern, Match)
import subprocess
import psutil

from sexpdata import Symbol

T = TypeVar('T')

def kill_process_and_children(process: subprocess.Popen):
for child in psutil.Process(process.pid).children(recursive=True):
child.kill()
process.kill()


def unwrap(a: Optional[T]) -> T:
assert a is not None
Expand Down