add proper port polling before submission
This commit is contained in:
parent
ff25f39f5d
commit
0925eb1020
@ -5,6 +5,7 @@ import subprocess
|
|||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import socket
|
||||||
|
|
||||||
# Force temp files into a folder inside your project (fully owned by you)
|
# Force temp files into a folder inside your project (fully owned by you)
|
||||||
custom_temp_dir = os.path.join(os.getcwd(), "tmp")
|
custom_temp_dir = os.path.join(os.getcwd(), "tmp")
|
||||||
@ -17,6 +18,32 @@ MVSHOST = "oldcomputernerd.com"
|
|||||||
RDRPORT = 3505
|
RDRPORT = 3505
|
||||||
MVS_PASSWORD = os.environ.get("MVS_BATCH_PASSWORD")
|
MVS_PASSWORD = os.environ.get("MVS_BATCH_PASSWORD")
|
||||||
|
|
||||||
|
def wait_for_port(host, port, timeout=30, poll_interval=1):
|
||||||
|
"""Wait for port to become available (not in use)"""
|
||||||
|
print(f"Waiting for port {port} on {host} to be ready...")
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
while time.time() - start_time < timeout:
|
||||||
|
try:
|
||||||
|
# Try to connect - if successful, port is available
|
||||||
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
sock.settimeout(2)
|
||||||
|
result = sock.connect_ex((host, port))
|
||||||
|
sock.close()
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
print(f"Port {port} is ready")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print(f"Port {port} not responding (error {result}), waiting...")
|
||||||
|
time.sleep(poll_interval)
|
||||||
|
except socket.error as e:
|
||||||
|
print(f"Socket error: {e}, retrying...")
|
||||||
|
time.sleep(poll_interval)
|
||||||
|
|
||||||
|
print(f"Timeout waiting for port {port} to be ready after {timeout}s")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def create_jcl_payload(local_file, dataset_name, member_name):
|
def create_jcl_payload(local_file, dataset_name, member_name):
|
||||||
|
|
||||||
@ -171,9 +198,10 @@ if __name__ == "__main__":
|
|||||||
if upload_source(local_file, dataset_name, member_name, mvshost) != 0:
|
if upload_source(local_file, dataset_name, member_name, mvshost) != 0:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Wait between submissions to avoid overwhelming the card reader
|
# Wait for card reader port to be ready before submitting compile job
|
||||||
print("Waiting 3 seconds before submitting compile job...")
|
if not wait_for_port(mvshost, RDRPORT, timeout=30):
|
||||||
time.sleep(3)
|
print(f"Error: Card reader port {RDRPORT} not available")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# Step 2: Submit JCL job
|
# Step 2: Submit JCL job
|
||||||
exit_code = submit_jcl(job, mvshost)
|
exit_code = submit_jcl(job, mvshost)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user