I'm not sure why it was done so previously. I moved the import to the top (now in buildslave.scripts.restart) and it seems to work without any problems.