accs self.q = Queue(maxsize=MAX_CONNS) def run(self): t1 = Thread( target=consumer, args=(self.q, self.accounts, self.participant) ); t1.start(); for _, creds in self.accounts.items(): t2 = Thread( target=producer, args=(self.q, creds, self.participant) ) t2.start()