job scheduling algorithm in python