schrodinger.utils.thread_utils module¶
Simplifies keeping track of threads, mainly for debugging. Allows threads to be named and provides a print function that prepends which info on what thread it is being called from. To use, either instantiate the class or use the global singleton via the module-level functions.
- class schrodinger.utils.thread_utils.ThreadTool[source]¶
Bases:
object
- getThreadId(name=None)[source]¶
Gets an integer id for a thread. If no name is provided, gets the id of the thread that is calling this method.
- Parameters
name (str) – a previously set name for a thread
- Returns
a thread id
- Return type
int
- getThreadName(tid=None)[source]¶
Gets the name of a thread if it has been previously set, otherwise just return a string representation of the thread id.
If no thread id is specified, use the id of the thread that is calling this method.
- Parameters
tid (int or None) – the id of the thread for which to retrieve the name
- Returns
the assigned name for the thread
- Return type
str
- setThreadName(name, tid=None)[source]¶
Set a user-friendly name for a thread.
If no thread id is specified, use the id of the thread that is calling this method.
- Parameters
name (str) – the name to assign (e.g. “main”, “worker”, “gui” etc.)
tid (int or None) – the id of the thread for which to set a name