射线:python 在 time.sleep 之后不打印
ray: python does not print after time.sleep
我用的是centos 8.2, python 3.6.8, ray 1.0.1 /3/, 我有python源代码写在/1/, 结果显示在/2 /,它只适用于第一次打印,但它不适用于第二次打印和第三次打印。 说我只是将 flush 参数放在 print 子句中,但它不起作用。
/1/
import ray
import time
ray.init();
@ray.remote
def f():
a = 3;
print("before print",flush=True);
time.sleep(1);
print("after print",flush=True);
time.sleep(2);
print("end",flush=True);
return 1;
f.remote()
f.remote()
f.remote()
/2/
[sjj@localhost exer1Sleep]$ export PYTHONUNBUFFERED=TRUE
[sjj@localhost exer1Sleep]$ python3 raySleep.py
2021-03-10 14:26:15,322 INFO services.py:1092 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=42437) before print
(pid=42438) before print
(pid=42442) before print
/3/
[sjj@localhost exer1Sleep]$ python3 --version
Python 3.6.8
[sjj@localhost exer1Sleep]$ ray --version
ray, version 1.0.1.post1
[sjj@localhost exer1Sleep]$
[已编辑,添加更多]
如果我删除 time.sleep,打印工作正常。 time.sleep 是什么让打印消失了?
/4/
import ray
import time
ray.init();
@ray.remote
def f():
a = 3;
print("before print",flush=True);
print("after print",flush=True);
print("end",flush=True);
return 1;
f.remote()
f.remote()
f.remote()
/5/
[sjj@localhost exer1Sleep]$ python3 raySleepWithout.py
2021-03-11 11:34:07,933 INFO services.py:1092 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=45246) before print
(pid=45246) after print
(pid=45246) end
(pid=45242) before print
(pid=45242) after print
(pid=45242) end
(pid=45245) before print
(pid=45245) after print
(pid=45245) end
在ray讨论区也提到了:
当前光线的问题。等待下一个版本。只需将日期标记为 2021 年 3 月 11 日。射线 1.0.1 post
我用的是centos 8.2, python 3.6.8, ray 1.0.1 /3/, 我有python源代码写在/1/, 结果显示在/2 /,它只适用于第一次打印,但它不适用于第二次打印和第三次打印。
/1/
import ray
import time
ray.init();
@ray.remote
def f():
a = 3;
print("before print",flush=True);
time.sleep(1);
print("after print",flush=True);
time.sleep(2);
print("end",flush=True);
return 1;
f.remote()
f.remote()
f.remote()
/2/
[sjj@localhost exer1Sleep]$ export PYTHONUNBUFFERED=TRUE
[sjj@localhost exer1Sleep]$ python3 raySleep.py
2021-03-10 14:26:15,322 INFO services.py:1092 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=42437) before print
(pid=42438) before print
(pid=42442) before print
/3/
[sjj@localhost exer1Sleep]$ python3 --version
Python 3.6.8
[sjj@localhost exer1Sleep]$ ray --version
ray, version 1.0.1.post1
[sjj@localhost exer1Sleep]$
[已编辑,添加更多]
如果我删除 time.sleep,打印工作正常。 time.sleep 是什么让打印消失了?
/4/
import ray
import time
ray.init();
@ray.remote
def f():
a = 3;
print("before print",flush=True);
print("after print",flush=True);
print("end",flush=True);
return 1;
f.remote()
f.remote()
f.remote()
/5/
[sjj@localhost exer1Sleep]$ python3 raySleepWithout.py
2021-03-11 11:34:07,933 INFO services.py:1092 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=45246) before print
(pid=45246) after print
(pid=45246) end
(pid=45242) before print
(pid=45242) after print
(pid=45242) end
(pid=45245) before print
(pid=45245) after print
(pid=45245) end
在ray讨论区也提到了:
当前光线的问题。等待下一个版本。只需将日期标记为 2021 年 3 月 11 日。射线 1.0.1 post