KxSystems / pyq

PyQ — Python for kdb+
http://code.kx.com/q/interfaces
Apache License 2.0
191 stars 49 forks source link

stdout from Python is always behind stdout from Q when direct stdout to a file #137

Closed xiangpeng2008 closed 4 years ago

xiangpeng2008 commented 4 years ago

Questions

PyQ 5.0.0 NumPy 1.18.4 KDB+ 3.6 (2018.06.14) m64 Python 3.7.7 (default, May 12 2020, 22:03:45) [Clang 11.0.0 (clang-1100.0.33.17)]

Steps to reproduce the issue

printf "p)print('python') \nshow \"q\"; \n\\\\\n" > test.q; cat test.q $VIRTUAL_ENV/q/m64/q test.q $VIRTUAL_ENV/q/m64/q test.q > test.log cat test.log

Expected result

python "q"

Actual result

"q" python

Workaround

If you know workaround, please provide it here.

sashkab commented 4 years ago

Did you try to use p)print('python', flush=True)?

$ cat test.q
p)print('python', flush=True)
show "q";
\
$ QHOME=$VIRTUAL_ENV/q  $VIRTUAL_ENV/q/m64/q test.q
python
"q"
xiangpeng2008 commented 4 years ago

Thanks !