def _setup_hardware(self): def send_subsequence(subseq): for msg in subseq: self._send_midi(msg) sequence_to_run = [ Task.run(partial(send_subsequence, subsequence)) for subsequence in split_list(self._messages_to_send, 20) ] self._tasks.add(Task.sequence(*sequence_to_run)) self._messages_to_send = []