在AWS Glu中在另一个Python Shell中调用Python UDF

2024-04-25 17:21:06 发布

您现在位置:Python中文网/ 问答频道 /正文

在将python UDF调用到另一个python shell中时出现错误(在Spyder中同样的方法工作得很好,但是在AWS Glue job中失败了)。你知道吗

我已经创建了自定义项及其完美的工作。我试图将UDF调用到另一个python Schell中,但它给出了一个错误(它的AWS Glue python脚本)。尝试了不同的方法仍然是同一个问题: 错误:-

Traceback (most recent call last):
File "/tmp/runscript.py", line 118, in <module>
runpy.run_path(temp_file_path, run_name='__main__')
File "/usr/local/lib/python3.6/runpy.py", line 261, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "/usr/local/lib/python3.6/runpy.py", line 236, in get_code_from_file
code = compile(f.read(), fname, 'exec')
File "/tmp/glue-python-scripts-wghizc7y/ACTION_END_POINT_MULTI.py", line 8
import API-Test
^
SyntaxError: invalid syntax

在处理上述异常时,发生了另一个异常:

    Traceback (most recent call last):
    File "/tmp/runscript.py", line 134, in <module>
    while "runpy.py" in new_stack.tb_frame.f_code.co_filename:
    AttributeError: 'NoneType' object has no attribute 'tb_frame'

代码:

    import urllib.request
    from multiprocessing import Pool
    import threading
    import boto3
    from API-Test import *


    def run_action():
        print("Process Started")
    try:
        if __name__ == "__main__":
            print("Process Came to Try Block")
            t0 = threading.Thread(target=run_action)

            t0.start()

            t0.join()

            print("Proces Complted")
    except(ValueError,KeyError,TypeError) as e:
        print(e)

Tags: pathrunnameinfrompyimport错误