PTB-CRITICAL: In call to PsychSetThreadPriority()

I’m getting the following error:

### Running: /home/bassam/code-workspaces/testpsychopy/firstTest_lastrun.py ####
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.

Regards
Jason

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
3 Likes

(post deleted by author)

I have done the above but still get the same error reported.

ubuntu version Ubuntu 22.04.3 LTS

Package Version


arabic-reshaper 3.0.0
astunparse 1.6.3
beautifulsoup4 4.12.2
blosc2 2.0.0
certifi 2023.11.17
cffi 1.16.0
charset-normalizer 3.3.2
contourpy 1.1.1
cryptography 41.0.7
cycler 0.12.1
Cython 3.0.6
dukpy 0.3.0
elementpath 4.1.5
esprima 4.0.1
et-xmlfile 1.1.0
ffpyplayer 4.5.1
fonttools 4.46.0
freetype-py 2.4.0
future 0.18.3
gevent 23.9.1
gitdb 4.0.11
GitPython 3.1.40
greenlet 3.0.1
html2text 2020.1.16
idna 3.6
imageio 2.33.0
imageio-ffmpeg 0.4.9
importlib-resources 6.1.1
javascripthon 0.12
jedi 0.19.1
json-tricks 3.17.3
kiwisolver 1.4.5
markdown-it-py 3.0.0
matplotlib 3.7.4
mdurl 0.1.2
msgpack 1.0.7
msgpack-numpy 0.4.8
numexpr 2.8.6
numpy 1.24.4
opencv-python 4.8.1.78
openpyxl 3.1.2
packaging 23.2
pandas 2.0.3
parso 0.8.3
Pillow 10.1.0
pip 23.3.1
psutil 5.9.6
psychopy 2023.2.3
psychtoolbox 3.0.19.0
py-cpuinfo 9.0.0
pycparser 2.21
pyglet 1.5.27
pyparallel 0.2.2
pyparsing 3.1.1
pypi-search 2.0
PyQt5 5.15.10
PyQt5-Qt5 5.15.2
PyQt5-sip 12.13.0
pyserial 3.5
python-bidi 0.4.2
python-dateutil 2.8.2
python-gitlab 4.2.0
python-vlc 3.0.20123
python-xlib 0.33
pytz 2023.3.post1
PyYAML 6.0.1
pyzmq 25.1.2
questplus 2023.1
requests 2.31.0
requests-toolbelt 1.0.0
scipy 1.10.1
setuptools 66.1.1
six 1.16.0
smmap 5.0.1
soundfile 0.12.1
soupsieve 2.5
tables 3.8.0
tzdata 2023.3
ujson 5.8.0
urllib3 2.1.0
websockets 12.0
wheel 0.41.2
wxPython 4.2.0
xarray 2023.1.0
xmlschema 2.5.0
zipp 3.17.0
zope.event 5.0
zope.interface 6.1

If you’re still getting the psychtoolbox realtime priority setting error after adding the permission to raise the setting then I don’t know any other tricks to make it work. You’ll need to use a different engine for collecting responses (e.g. iohub)