This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Invoke a Compiled MATLAB Function Asynchronously

Asynchronously invoke a compiled MATLAB® function that uses the Python® object returned from the initialize() function by passing async = True.

future = my_client.function_name(in_args, nargout=nargs,
  • my_client — Name of object returned from initialize()

  • function_name — Name of the function to invoke

  • in_args — Comma-separated list of input arguments

  • nargs — Number of results expected from the server

  • out_stream — Python StringIO object receiving the console output

  • err_stream — Python StringIO object receiving the error output

When the async keyword is set to True, the MATLAB function is placed into a processing queue and a Python Future object is returned. You use the Future object to retrieve the results when the MATLAB function is finished processing.

To invoke the MATLAB function c1,c2= copy(o1,o2) from the package copier asynchronously, use the following code:

>>> import mutations
>>> import matlab
>>> myMutator = mutations.initialize()
>>> m1 = matlab.double([1,2,3])
>>> m2 = matlab.double([10,20,30])
>>> m3 = matlab.double([100,200,300])
>>> resultFuture = myMutator.mutate(m1,m2,m3, async=True)
>>> while !resultFuture.done():
...    time.sleep(1)
>>> result = resultFuture.result()


You can cancel asynchronous requests using the cancel() method of the Future object.

Related Topics