Decorators

class gaphas.decorators.g_async(single: bool = False, timeout: int = 0, priority: int = 200)[source]

Instead of calling the function, schedule an idle handler at a given priority. This requires the async’ed method to be called from within the GTK main loop. Otherwise the method is executed directly.

If a function’s first argument is “self”, it’s considered a method.

Calling the async function from outside the gtk main loop will yield immediate execution.

A function can also be a generator. The generator will be fully executed. If run in the main loop, an empty iterator will be returned. A generator is “single” by default. Because of the nature of generators the first invocation will run till completion.

gaphas.decorators.nonrecursive(func)[source]

Enforce a function or method is not executed recursively:

>>> class A(object):
...     @nonrecursive
...     def a(self, x=1):
...         print(x)
...         self.a(x+1)
>>> A().a()
1
>>> A().a()
1