除了传统的使用 PyDataLog 的方式之外,还有其他在 CherryPy 中使用 PyDataLog 的方式吗?

Is there another way to use PyDataLog in CherryPy than the conventional way of using PyDataLog?

我在 500 internal server error 页面中遇到如下错误。

File "/usr/local/lib/python3.5/dist-packages/pyDatalog/pyParser.py", line 388, in __call__
    literal = Literal.make(self._pyD_name, tuple(args), kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pyDatalog/pyParser.py", line 510, in make
    return precalculations & Query(predicate_name, terms, kwargs, prearity, aggregate)
  File "/usr/local/lib/python3.5/dist-packages/pyDatalog/pyParser.py", line 574, in __init__
    Literal.__init__(self, predicate_name, terms, kwargs, prearity, aggregate)
  File "/usr/local/lib/python3.5/dist-packages/pyDatalog/pyParser.py", line 500, in __init__
    self.lua = pyEngine.Literal(self.predicate_name, tbl, self.prearity, aggregate)
  File "pyDatalog\pyEngine.py", line 402, in pyDatalog.pyEngine.Literal.__init__ (pyDatalog/pyEngine.c:15254)
  File "pyDatalog\pyEngine.py", line 333, in pyDatalog.pyEngine.Pred.__new__ (pyDatalog/pyEngine.c:13917)
  File "pyDatalog\pyEngine.py", line 334, in pyDatalog.pyEngine.Pred.__new__ (pyDatalog/pyEngine.c:13431)
AttributeError: '_thread._local' object has no attribute 'logic'

如何访问 PyDataLog 变量

我在 Thread safety and multi-models 部分找到了答案 here。如果它可以帮助其他人面对我所面临的问题。

一个Python程序可能会启动多个线程。每个线程都应该有这些语句来初始化 pyDatalog :

from pyDatalog import pyDatalog, Logic
Logic() # initializes the pyDatalog engine