No response on Cedrus RB-740 is throwing an error (pop from empty list)

Hi there,

I have been trying to get response from Cedrus RB-740 using pyxid2 (PsychoPy). I am getting the response when button is pressed. But when I give a timeout its throwing an error.
This is the code:

devices = pyxid2.get_xid_devices()

dev = devices[0]

start_timer = clock.getTime()
if dev.is_response_device():
    print ("Press a key!")
    while not dev.has_response():
        stop_timer = clock.getTime()
        rt = round(stop_timer - start_timer,5)*1000
        if rt>500:
    response = dev.get_next_response()
    response['time'] = rt

<XidDevice “Cedrus RB-740”>
Press a key!
Traceback (most recent call last):
File “response pad”, line 23, in
response = dev.get_next_response()
File “C:\Program Files\PsychoPy\lib\site-packages\pyxid2\”, line 241, in get_next_response
return self.response_queue.pop(0)
IndexError: pop from empty list

Python version: 3.10.2
Psychopy version: 2021.2.3
Windows 10 OS
All 64 bit

Any suggestions are appreciated. Thanks in advance!

I ran your question by a developer. The error is because when you call "response = dev.get_next_response()”, there are no responses to get. Looking at the code, this is probably because the timer runs out and breaks the response polling loop before a button can be pressed. We can probably modify get_next_response() to return None in that case or something , rather than crashing.

For now, the remedy is to check with has_response() before calling get_next_response().

I hope this helps.

1 Like