KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums PyKX PyKX could not establish an IPC connection in the Flask app Re: PyKX could not establish an IPC connection in the Flask app

  • supersaiyanraj

    Member
    February 8, 2024 at 12:00 am

    Hello ,I tried the same with both pykx 2.2.0 /2.3.0 , python 3.10.9 , Flask 3.0.2, I can’t able to connect with port 5000.

    from flask import Flask 
    import pykx as kx 
    import json as j 
    app = Flask(__name__) 
    
    @app.route("/") 
    def hello_kx(): 
         import pykx as kx 
         qcon=kx.QConnection(host='localhost', port=5000) 
         tables=qcon("tables[]").py() 
         import json as j 
         print(j.dumps(ports)) 
         return tables 
    
    if __name__ == '__main__': 
         app.run(host='127.0.0.1', debug=True, port=8100)

    I got this error:

    if q(‘{.pykx.util.isw x}’, self).py():

    File “/rxds/rxds_offerings/datagen/env/lib/python3.10/site-packages/pykx/embedded_q.py”, line 226, in __call__return factory(result, False)

    File “pykx/_wrappers.pyx”, line 507, in pykx._wrappers._factory

    File “pykx/_wrappers.pyx”, line 500, in pykx._wrappers.factory

    pykx.exceptions.QError: .pykx.util.isw

    the same code I just run python without flask it return values.

    import pykx as kx 
    import json 
    
    def hello_kx(): 
         qcon=kx.QConnection(host='localhost', port=5000) 
         tables=qcon("tables[]").py() 
         import json 
         return json.dumps(tables)
    
    a=hello_kx() 
    print(a)