psychopy.org | Reference | Downloads | Github

What's wrong when' exception in thread Thread-12'

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
PsychoPy version (e.g. 1.84.x):
Hi, psychopy users, I met a new problem when I tried to record ERP throug trigger box.


I don’t know how to handdle it, any advice would be appreciated.

Could you provide the entire error (including the traceback) and describe what components or code you are using that leads to this error?

I’m assuming your using the psychopy.parallel functions if you’re trying to read triggers. What is your code for that?

Thank you for your replying. My experiment is an oddball task : reacting to the small odd picture–big boy , and ignoring others(small boy and teacher).
Indeed it was problem about trigger, I missed the code called ‘thread’.Then I followed another post : https://discourse.psychopy.org/t/send-ttl-from-psychopy-to-brainamp-eeg-system/5763,but I met a new problem named ‘UnicodeDecodeError’


And my builder design and codes are:




I guse ‘port.read([0x00])’ or ‘port.read([0x01])’ couldn’t be decode.Do you have any suggestion or better way to code for making marker?
Thanks a lot!

I think the error is unrelated to your parallel port code. It seems to be connected to your conditions file conds.csv. Could it be that you used an encoding other than utf-8, when you saved the conds.csv?

YES, it was the format problem in the conds.csv.Thanks for your reminding.
However,after I fixed the that, the’Exception in thread Thread 12’ poped up again like the first photo I put .Can you give me some advice about that?
PS :After ‘Exception in thread Thread 12:’ ,it said nothing but’Traceback(most recent last):’,then the psychopy output exit

The screenshot you posted in your original post is confusing, because I can see the trace-back for an error at the top and I’m not sure if that is related. Could you:

  1. Open Psychopy or close and open it up again (at the moment, there is no other way to clear the Stdout)
  2. Run your experiment until the error occurs.
  3. Set your cursor in the Stdout window and press Ctrl + A to select all output.
  4. Copy the output here as preformatted text.

I’m no expert in threading, but I’ll try to help. Perhaps someone with more expertise in pyserial and threading can then chip in.

What is it exactly that you are trying to achieve? You want to both read from and write to a serial.Serial port?

Are you sure that it is possible to read from and write to the serial port simultaneously from different threads?

You’re trying to print out the data you receive from your serial.Serial port. If you’re reading from an Encephalograph to record Event-Related-Potentials, that seems like an awful lot of data to print out to the Stout. The print function and the functions you use to construct the string that you print out take some time (you can test that with the timeit module). Even if you’re recording the EEG just at 256 Hz, this time will sum up.

The serial.Serial.read() method returns a bytes object. I don’t think, ord takes a byte object as an argument.

I see, you’re using serial.Serial.inWaiting. The new name of the function is serial.Serial.in_waiting.