Help Center/ FunctionGraph/ FAQs/ Migration from FunctionGraph V1 to V2/ What Compatibility Issues Exist During the Migration?
Updated on 2022-08-19 GMT+08:00

What Compatibility Issues Exist During the Migration?

  1. args difference
    V1:
    args = parser.parse_args()

    After migration to V2, it will be:

    args = parser.parse_args(args=[])

    The sys.argv of Python runtime varies between the two versions.

    For V2, it is ['/home/snuser/runtime/python3.6/server.py', '127.0.0.1:31536', '/opt/function/code'], whose last two parameters are not available for V1.

  2. asyncio difference
    V1:
    loop = asyncio.get_event_loop()
    loop.run_until_complete(func(arg1, arg2))
    loop.close()

    After migration to V2, it will be:

    loop_tmp = asyncio.new_event_loop()
    asyncio.set_event_loop(loop_tmp)
    loop = asyncio.get_event_loop()
    loop.run_until_complete(func(arg1, arg2))
    loop.close()

    In V1, asyncio.get_event_loop() obtains the current event loop from the OS thread (main thread). It will throw RuntimeError in V2, because Python runtime of V2 does not run functions in the main thread.

    To use asyncio in V2, create an event loop.