Search code examples
pythoncherrypypydatalog

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


I am getting error like this below in the 500 internal server error page.

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'

How can access the PyDataLog variables


Solution

  • I have found the answer here in the Thread safety and multi-models section. If it can help anyone else facing what I faced.

    A Python program may start several threads. Each thread should have these statements to initialize pyDatalog :

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