libavg lets you work with several Python threads. However, calling libavg methods from secondary threads naively will not work and can cause crashes - you need to add some support code. This article explains the background and shows what to do if you have more than one thread.

In normal Python execution, only one thread is running at a time. This is a general CPython issue: The interpreter uses a single Global Interpreter Lock (GIL - http://wiki.python.org/moin/GlobalInterpreterLock) to serialize execution of Python code. However, there is no reason to disallow Python execution while libavg is rendering a frame, so libavg explicitly releases the lock when it starts rendering and re-aquires it when it's done rendering. The result is that secondary Python threads can run on another core while libavg is rendering, which is a Good Thing (in general).

The caveat is that if you call a libavg method from a secondary thread, you might be executing it while it's halfway through rendering. Depending on the exact circumstances (e.g. deleting a node while it's being rendered), this will often cause a crash. Thus, in general, you can't call libavg methods in secondary threads.