import subprocess from gee import main def create_tmux_session(session_name, start_index, end_index): try: # Create new tmux session detached subprocess.run(['tmux', 'new-session', '-d', '-s', session_name]) # Send the Python command to the tmux session command = f'python3.8 -c "from gee import main; main({start_index}, {end_index})"' subprocess.run(['tmux', 'send-keys', '-t', session_name, command, 'C-m']) print(f"Started session {session_name} processing indices {start_index} to {end_index}") except Exception as e: print(f"Error creating session {session_name}: {str(e)}") def main(): session_number = 1 for i in range(1, 421, 20): end_index = min(i + 20, 421) # Ensure we don't go beyond 420 session_name = f'm{session_number}' create_tmux_session(session_name, i, end_index) session_number += 1 if __name__ == "__main__": main()