PTB-CRITICAL: In call to PsychSetThreadPriority()

I’m getting the following error:

### Running: /home/bassam/code-workspaces/testpsychopy/ ####
PTB-CRITICAL: In call to PsychSetThreadPriority(): Failed to set new basePriority 2, tweakPriority 1, effective 1 [REALTIME] for thread (nil) provided!
PsychHID: KbQueueStart: Failed to switch to realtime priority [Operation not permitted].
##### Experiment ended. #####

After I hit run, it asks for the participant name, the whole screen goes grey for half a second and then it stops. My experiment has nothing in it except for a text stimuli that displays “hello” for 5 seconds.

It does run from the website however.

What could be the problem?

1 Like

The error seems to be connected to the Psychtoolbox Python package. You don’t get any errors online, because the JS script translation of your Psychtoolbox code has nothing to do with Psychtoolbox. The JS equivalent uses entirely different code to produce a similar effect.

Do you want to run your experiment offline? Are sound latencies or keyboard reaction times important for you?

What is your operating system? Do you use the standalone version?

Hi Lukas and Bassam,

I am getting the same error as Bassam. Interestingly, when I run a demo, the code works, but when I create my own simple code (e.g. a Hello World) script, the error occurs. I am continuing to debug however can you provide any insight into this?

I note the response indicating an error with the Psychtoolbox package for Python. I will start here.


We really do need to know the operating system to answer this one. If you’re using ubuntu then this is the issue:

To get psychtoolbox working for keyboard use you need the following steps to raise the priority of the experiment process. The idea is that to give you permission to do this without using super-user permissions to run your study (which would be bad for security) you need to add yourself to a group (e.g create a psychopy group) and then give that group permission to raise the priority of our process without being su:

sudo groupadd --force psychopy
sudo usermod -a -G psychopy $USER

then do sudo nano /etc/security/limits.d/99-psychopylimits.conf and copy/paste in the following text to that file:

@psychopy   -  nice       -20
@psychopy   -  rtprio     50
@psychopy   -  memlock    unlimited

(post deleted by author)