Downloading Resources On the Fly

My goal is to download resources (images) as needed on each trial, and to do so with “blocking” such that the experiment pauses until the resources are available. Using version 2020.2 I was able to download via:
However, it did not appear to be blocking, and with version 2021.2.3 I receive an error that this function is not defined. I get the same error with function:
which was also not blocking in previous versions, but is claimed to be here

From looking at the source code I found the very similar function
(note the underscore before “download”). This seems to be defined in the new version, but also appears to be non-blocking.

My hope was that moving to 2021.2.3 would provide better resource downloading with blocking, and thought perhaps such functionality was included but with a different function name that I just can’t find? Any help is greatly appreciated!

Screenshot from 2021-11-22 16-59-54

In 2021.2.3 onwards, try using psychoJS._serverManager.prepareResources() instead.

Thank you, prepareResources() seems to work great, and appears to be blocking (although I haven’t done extensive testing to be sure yet)!

Oh no, I believe I spoke too soon: the prepareResources() call does not appear to be blocking. I.e. an attempt to use the resource after calling this function will occasionally error, in cases when the download hasn’t completed before the subsequent call to use the resource. A while back you recommended inserting a test for completed download within the routine, which seems straightforward. But if there is a more appropriate implementation in 2021.2.3 I would be very grateful for any suggestions!

I was about to search for that suggestion and point you towards it.