treasure-data / digdag

Workload Automation System
https://www.digdag.io/
Apache License 2.0
1.31k stars 221 forks source link

Unable to exit as success status when using sys.exit(0) from py:> operator #1771

Closed s-furu closed 1 year ago

s-furu commented 1 year ago

digdag 0.10.4 python 3.9.2

I want to exit from py file as success status, but the bellow script does not finish as success status but as failure status.

import sys

def success_job():
    sys.exit(0)

The error message is here.

Error messages from python: Failed to call python command with code:0 Possible cause: Ivalid python module call, duplicae module name with standard library (SystemExit)

Is any module in Java interfering with python sys module?

hiroyuki-sato commented 1 year ago

Hello, @s-furu

I think you can't use sys.exit because py> operator use runner.py. It calls your script.

What do you think about using return instead of sys.exit?

The following example doesn't raise an exception.

class MyClass(object):
    def print_time(self):
        return
        raise Exception("HOGEHOGE")
timezone: UTC

+setup:
  py>: scripts.myclass.MyClass.print_time

Otherwise, you can use sh> operator.

s-furu commented 1 year ago

Hi @hiroyuki-sato,

I understand the internal process. Thank you for the navigation and the alternative manner!