Python: Socket and threads?
Unfortunately,The socket shared by multi-thread is not thread safe.Think about buffer two threads operate on with no lock.
The normal way to implement is with two socket,just like what ftp does.cmd socket and msg socket.
If you wanna implement this by one socket,you can put different type msgs into different queues,and with a third thread consumes the queue and send them through the only socket.
In this way,you can control heartbeat msg priory to data msg.
Python - multithreaded sockets
Your understanding of how Threads work in Python seems to be incorrect, based on the question you are asking. If used correctly, threads will not be blocking: you can instantiate multiple thread with Python. The limitation is that, due to the Global Interpreter Lock (GIL), you cannot get the full parallelism expected in thread programming (e.g. simultaneous execution and thus, reduced runtime).
What is going to happen in your case is that the two threads will take, together, the same amount of time that they would take if they were executed sequentially (although that is not necessarily what happens in practice).
Related Topics
How to Get Rid of Double Backslash in Python Windows File Path String
How to Remove Packages Installed with Python's Easy_Install
Unpacking a List/Tuple of Pairs into Two Lists/Tuples
Python: Count Repeated Elements in the List
How to Replace Two Things at Once in a String
Best Way to Preserve Numpy Arrays on Disk
How to Create Key or Append an Element to Key
How to Plot a Gradient Color Line in Matplotlib
How to Kill a Process on Windows from Within Python
Optimal Hdf5 Dataset Chunk Shape for Reading Rows
Python: Source Code String Cannot Contain Null Bytes
Scraping Google Finance (Beautifulsoup)
Grouping/Clustering Numbers in Python