聚合国内IT技术精华文章,分享IT技术精华,帮助IT从业人士成长

How to gracefully end a PySpark application

2021-02-12 12:18 浏览: 319 次 我要评论(0 条) 字号:

This article recommend using “return” to jump out of a PySpark application. But after I did by following what he said. It reports error:

  File "test.py", line 333
    return
    ^
SyntaxError: 'return' outside function

Seems it can’t work. After trying to run PySpark application on my own laptop, I finally got the correct answer:

import sys

if df.rdd.isEmpty():
  sys.exit(0)


网友评论已有0条评论, 我也要评论

发表评论

*

* (保密)

Ctrl+Enter 快捷回复