cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
190 stars 109 forks source link

Take full advantage of asynchronous request execution #813

Closed MariusWirtz closed 9 months ago

MariusWirtz commented 2 years ago

There is currently no way to take full advantage of asynchronous request execution (asnyc_requests_mode).

It would be nice if TM1py could return the job-id to the calling function. This way python scripts could easily do stuff in parallel while polling the operations in TM1 to see if they are finished yet.

Reference: https://gist.github.com/rclapp/2d6d8d389b99838d6e0fec18642e658f

MariusWirtz commented 9 months ago

Feature is implement for execute_process_with_return function with #1000 and #1035

This will be rolled out to other functions gradually over the next releases.

Example:

with TM1Service(**tm1params) as tm1:
    async_id = tm1.processes.execute_with_return(
        process_name="}bedrock.server.wait",
        pWaitSec=10,
        return_async_id=True)

    done = None
    while not done:
        time.sleep(1)
        done = tm1.processes.poll_execute_with_return(async_id)

    success, status, error_log_file = done
    print(success, status, error_log_file)
MariusWirtz commented 9 months ago

@rkvinoth, @ivankulman, @macsir Beyond execute_with_return to which functions should we introduce the new parameter return_async_id?