Fix for race condition during scheduler registration when there are multiple builds on queue

Fix for race condition during scheduler registration(on demand) when there are multiple builds on queue