Menu

can't get realtime tcp msg

Help
pinkiecao
2016-08-12
2016-08-15
  • pinkiecao

    pinkiecao - 2016-08-12

    Dear all:
    I'm writing a activeMQ client with pythonQt and activemq python files. A tcp client connects server and receive data in a loop(a thread) in one python.py. Python will notify Qt app when tcp socket receives any msg.

    My problem is that the first received  mag isn't be notified and postponed  until I send a msg out.so I always got the last received msg when i sent a new msg. I got no msg notification if no msg was out. I try to run the .py in Python IDE,and it runs ok. I try to start a timer(rate:3s) in Qt application to call a function of one py file ,my problem disapears.
    
    If anyone encountered such problem,and any help will be appreciated.
    
     
  • Florian Link

    Florian Link - 2016-08-12

    PythonQt does not support multithreading. You need to do this in the main thread with signal/slot connections to the socket.

     
  • pinkiecao

    pinkiecao - 2016-08-15

    hi Florian Link,
    Thanks for your quick reply. I'm not very clear about the 'multithreading'.In my project , python .py starts a new thread to receive socket data .The pythonObFactory or pythonOb is not used in multithread. The following is my calling steps:

    1.start my Qt app and create a pythonObFactory named objFactory
    2.pythonob = objFactory .evalScript("AMQPythonClient()\n",Py_eval_input);//create a py class object
    3.pythonOb.addObject("CNSPythonAMQClient", this); //register a qt class
    4.pythonob.call("connect",QVariantList());//in python ,connect to tcp server and start a thread to loop receive data
    5. AMQPythonClient gets notifcation with received data and calls slot of CNSPythonAMQClient to transfer data.

    so do you mean pythonQt doedn't work when python *.py applies multithreading ?Thanks a lot.

     
  • Florian Link

    Florian Link - 2016-08-15

    Yes, the python thread will only get scheduled when the main thread is inside of the Python interpreter, because PythonQt does not release the GIL. Google for GIL for more details on Python threading...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.