Spaces:
Running
Running
ZeroCommand
commited on
Commit
•
e631fcc
1
Parent(s):
f04482d
fix pipe io bug
Browse files- io_utils.py +9 -5
io_utils.py
CHANGED
@@ -95,13 +95,17 @@ def save_job_to_pipe(id, job, lock):
|
|
95 |
def pop_job_from_pipe():
|
96 |
if not os.path.exists(PIPE_PATH):
|
97 |
return
|
98 |
-
with open(PIPE_PATH, "r
|
99 |
-
|
100 |
-
f.
|
101 |
f.close()
|
102 |
-
|
|
|
|
|
|
|
|
|
103 |
return
|
104 |
-
job_info =
|
105 |
if len(job_info) != 2:
|
106 |
raise ValueError("Invalid job info: ", job_info)
|
107 |
print(f"Running job {job_info}")
|
|
|
95 |
def pop_job_from_pipe():
|
96 |
if not os.path.exists(PIPE_PATH):
|
97 |
return
|
98 |
+
with open(PIPE_PATH, "r") as f:
|
99 |
+
job = f.readline().strip()
|
100 |
+
remaining = f.readlines()
|
101 |
f.close()
|
102 |
+
print(job, remaining, ">>>>")
|
103 |
+
with open(PIPE_PATH, "w") as f:
|
104 |
+
f.write("\n".join(remaining))
|
105 |
+
f.close()
|
106 |
+
if len(job) == 0:
|
107 |
return
|
108 |
+
job_info = job.split('\n')[0].split("@")
|
109 |
if len(job_info) != 2:
|
110 |
raise ValueError("Invalid job info: ", job_info)
|
111 |
print(f"Running job {job_info}")
|