def threaded(queue): Scheduler.enter_critical("a") queue.put("%s_%s" % (currentThread().name, "a")) Scheduler.leave_critical() Scheduler.enter_critical("b") queue.put("%s_%s" % (currentThread().name, "b")) Scheduler.leave_critical()
def scheduler_basic(self, procs=2, events=None): threads = [] q = Queue() for num in range(procs): thread = Thread(target=threaded, args=(q,)) thread.name = num threads.append(thread) Scheduler.events = list(events) [t.start() for t in threads] Scheduler.schedule() [t.join() for t in threads] result = [] while not q.empty(): result.append(q.get()) return result