improvements
This commit is contained in:
parent
1e118bee6d
commit
e4c82910a2
@ -21,6 +21,7 @@ kernel_json = {
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
||||
class YAPKernel(IPythonKernel):
|
||||
implementation = 'MetaKernel YAP'
|
||||
implementation_version = '1.0'
|
||||
@ -41,10 +42,14 @@ class YAPKernel(IPythonKernel):
|
||||
}
|
||||
|
||||
def init_yap(self, **kwargs):
|
||||
# Signal handlers are inherited by forked processes, and we can't easily
|
||||
# reset it from the subprocess. Since kernelapp ignores SIGINT except in
|
||||
# message handlers, we need to temporarily reset the SIGINT handler here
|
||||
# so that yap and its children are interruptible.
|
||||
# Signal handlers are inherited by
|
||||
# forked processes,
|
||||
# and we can't easily
|
||||
# reset it from the subprocess. Since kernelapp
|
||||
# ignores SIGINT except in
|
||||
# message handlers, we need to temporarily
|
||||
# reset the SIGINT handler
|
||||
# here so that yap and its children are interruptible.
|
||||
sig = signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
try:
|
||||
self.engine = yap.YAPEngine()
|
||||
@ -64,14 +69,13 @@ class YAPKernel(IPythonKernel):
|
||||
def get_usage(self):
|
||||
return "This is the YAP kernel."
|
||||
|
||||
|
||||
def yap_run_cell(self, s, store_history=False, silent=False, shell_futures=True):
|
||||
def yap_run_cell(self, s, store_history=False, silent=False,
|
||||
shell_futures=True):
|
||||
|
||||
if not self.q:
|
||||
self.q = self.engine.query(s)
|
||||
if self.q.next():
|
||||
myvs = self.q.namedVarsCopy()
|
||||
wrote = False
|
||||
if myvs:
|
||||
i = 0
|
||||
for peq in myvs:
|
||||
@ -84,7 +88,6 @@ class YAPKernel(IPythonKernel):
|
||||
else:
|
||||
i = bind.numberVars(i, True)
|
||||
print(name.text() + " = " + bind.text())
|
||||
wrote = True
|
||||
print("yes")
|
||||
if self.q.deterministic():
|
||||
self.closeq()
|
||||
|
Reference in New Issue
Block a user