Threads

Functions for working with threads in Qt applications. Usually for dealing with running in the main event loop (e.g. thread) or not.

These functions are known to work as reasonable replacements for the functions provided by both Maya and Nuke.

We want to be able to use these functions and have them present reasonable actions even if there is no event loop. In most cases, that means immediately calling the function.

Another large benefit of these functions is that they are re-rentrant, unlike the functions provided in either Maya or Nuke which will lock up the main thread if called from the main thread.

uitools.threads.defer_to_main_thread(func, *args, **kwargs)[source]

Call the given function in the main thread, but don’t wait for results.

If an exception is thrown, a traceback will be printed.

This function is re-entrant, and calling from the main thread will call the passed function immediately (discarding the result).

If Qt is not running, it will call the function immediately.

uitools.threads.call_in_main_thread(func, *args, **kwargs)[source]

Call the given function in the main thread, and wait for results.

If an exception is thrown, it will be reraised here.

This function is re-entrant, and calling from the main thread will call the passed function immediately.

If Qt is not running, it will call the function immediately.

uitools.threads.is_main_thread()[source]

Return True if this is in the main thread (or Qt is not running).

Project Versions

Previous topic

uitools

Next topic

Trampoline to Main Thread

This Page