【问题标题】:Is there another way to use PyDataLog in CherryPy than the conventional way of using PyDataLog?除了使用 PyDataLog 的传统方式之外,还有另一种在 CherryPy 中使用 PyDataLog 的方法吗?
【发布时间】:2018-12-07 06:45:25
【问题描述】:

我在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 变量

【问题讨论】:

  • @Joshpbarron 不重复。这与 Cherrypy 和 PyDataLog 有关。我已经看到你提到的内容,发现它没有帮助。所以请删除标志。

标签: python cherrypy pydatalog


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-08
    • 1970-01-01
    • 2019-10-16
    • 2012-10-01
    • 2017-04-24
    • 2023-01-23
    • 1970-01-01
    • 2018-03-01
    相关资源
    最近更新 更多