'Takes a list of order_ids, writes them to a tempfile, and then runs the
"retire_order" command on the tempfile'

def _create_tempfile_and_call_command(self, order_ids):

    with NamedTemporaryFile() as temp:
        temp.write('\n'.join((str(order_id) for order_id in order_ids)))
        temp.seek(0)
        call_command('retire_order', temp.name)
