Skip to content
 
 

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TouchDesigner-asyncio

TDAsyncIO.tox is a Component for using the asyncio module in TouchDesigner without blocking the TD's main thread by running the event loop only once at the start of every frame.

Usage

Parameters

  • Active - The Event Loop can run asynchronous tasks while 'Active' is enabled
  • Cancel All Tasks - Cancel all tasks you created.

Methods

    @property
    def Loop(self):
        """
	Returns the Loop specified for this instance of TDAsyncIO.
	Each instance of the COMP has itws own eventLoop.
	"""
        pass

    def RunSync(self, coroutines: Union[List[Awaitable], Awaitable]) -> List[Any]:
        """
	Runs all passed routines concurrent, but stalls the process and returns the returnvalues as a list.
	"""
        pass

    def RunAsync(self, coroutines: Union[List[Awaitable], Awaitable]) -> List[asyncio.Task]:
        """
	Runs all routines concurrently and returns a list of tasks.
	"""
        pass

    def Cancel(self, killList=[]):
        """
	Cancels all tasks currently active or the defines task in the list.
	"""
        pass

Code example

import asyncio

async def test():
    await asyncio.sleep(3)
    print('hello world')

# Run coroutine
routineFutures = op("TDAsyncIO").RunAsync(test())
routineResult = op("TDAsyncIO").RunSync(test())

async def dealyedPrint(text):
    await asyncio.sleep(1)
    print(text)

several = op("TDAsyncIO").RunAsync([
    delayedPrint("Foo"), delayedPrint("Bar")
])


# Cancel all tasks
op("TDAsyncIO").Cancel()

License

MIT

About

No description, website, or topics provided.

Resources

Stars

12 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages