End/exit 以编程方式进行粘合作业
End/exit a glue job programmatically
我正在使用 Glue 书签来处理数据。我的工作每天都安排,但也可以“手动”启动。由于我使用书签,有时 Glue 作业可以在没有要处理的新数据的情况下启动,然后读取的数据框为空。在这种情况下,我想适当地结束我的工作,因为它无关紧要。
我试过了:
if df.rdd.isEmpty():
job.commit()
sys.exit(0)
但是,我的工作因 SystemExit: 0
错误终止。
如何成功结束作业?
经过一些测试,我从 @Glyph's answer 中发现:
os._exit()
terminates immediately at the C level and does not perform any of the normal tear-downs of the interpreter.
这正是我要找的。最终的解决方案是:
import os
if df.rdd.isEmpty():
job.commit()
os._exit()
我正在使用 Glue 书签来处理数据。我的工作每天都安排,但也可以“手动”启动。由于我使用书签,有时 Glue 作业可以在没有要处理的新数据的情况下启动,然后读取的数据框为空。在这种情况下,我想适当地结束我的工作,因为它无关紧要。 我试过了:
if df.rdd.isEmpty():
job.commit()
sys.exit(0)
但是,我的工作因 SystemExit: 0
错误终止。
如何成功结束作业?
经过一些测试,我从 @Glyph's answer 中发现:
os._exit()
terminates immediately at the C level and does not perform any of the normal tear-downs of the interpreter.
这正是我要找的。最终的解决方案是:
import os
if df.rdd.isEmpty():
job.commit()
os._exit()