Two contexts - glReadPixels

Hi I have OpenGL rendering server that sends rendered images based on request. Basic princip is simple: 1) get request 2) render to texture(pbuffer or fbo), call glReadPixels 3) send image.

Problem is when too many requests are pending. GPU stalls when I call glReadPixels.

Can it be solved by using two contexts in different threads ? Doesn’t glReadPixels in one thread blocks all gl* operations on another ?

Btw. is there better solution ? Async reading with two PBOs doesnt work very well, because there is very problematic balancing between incoming requests and reading pixels (I dont know if its better to render next request and wait for image to copy to cpu memory - but rendering can be very long and first request finish will take forever - or copy image right away - but another request may arrive and im copying pixels instead of rendering). The main problem: no signalisation in OpenGL whether reading pixels to cpu is done).

no signalisation in OpenGL whether reading pixels to cpu is done

Nonsense. Just use a fence sync object.

thx, I missed that, but I really want to know the answer to first question:
Does glReadPixels in one thread stalls gl* operations on another thread if a have two contexts ?