Coder Social home page Coder Social logo

Comments (3)

abalkin avatar abalkin commented on June 19, 2024

This is expected behavior. When you run pyq, q event loop is blocked in a call to Python's main loop. To avoid this, you should call python from a regular q session. For example:

Server side:

$ q
KDB+ 3.4 2016.06.14 ..
q)p)from pyq import q
q)p)def f(): print 'Hello';return q('42') # make sure to return a K object
q)p)q.f = f   # export f to q (make sure not to delete f in python)
q)f()  / check that we can call f locally
Hello
42
q)\p 1024  /  now open the communication port

Client side:

$ q
KDB+ 3.4 2016.06.14 ..
q)`::1024 "f()"
42

and 'Hello' is printed on the server side.

If you don't want to prefix every line with p) you can put your python code in a file with .p extension and load it from q

$ cat f.p
from pyq import q
def f():
    print 'Hello'
    return q('42')
q.f = f
$ q
KDB+ 3.4 2016.06.14 ..
q)\l f.p
q)f()
Hello
42

from pyq.

sitsang avatar sitsang commented on June 19, 2024

Actually, I am using PyQ inside Apache Spark via pyspark, so the server's entry point must be from python.

Can you show me where the event loop is blocked in the python's main loop?

from pyq.

abalkin avatar abalkin commented on June 19, 2024

Can you show me where the event loop is blocked in the python's main loop?

At this line in python.q. Note that the pyq command is more or less q python.q.

from pyq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.