I am new to python as well as scientific experimental setups. My experimental setup includes that subjects would be shown some visual stimuli which is programmed in Python. While subjects are looking at those visual stimuli their eyes' data would be recorded using an eye tracker (Pupil Labs). Pupil Labs is an open source platform, it also provides this facility that it broadcasts data (i.e. gaze or eye movements) to a server using TCP socket.
Now I am planning to log all the data, like when a particular stimuli is displayed as well as logging eye movement's data received from server. Problem is to synchronize these two things like at particular time some 'xyz' stimuli was shown and I want log what exactly the eye data was at that particular time.
I am writing the code in Python, so far what happening is there is a main program which shows stimuli using psychopy library. In that main program there is a thread which receives data from server.
I want to know how can I synchronize this task. I am new to such task also I am not sure what to look for over internet. I will be grateful for your help.