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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
PythonQt does not support multithreading. You need to do this in the main thread with signal/slot connections to the socket.
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.
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...