Remove nonrecursive decorator

This commit is contained in:
Arjan Molenaar 2024-08-17 19:51:36 +02:00
parent 05b7d0b2d3
commit a3627e7547
3 changed files with 0 additions and 31 deletions

View File

@ -2,5 +2,3 @@ Decorators
==========
.. autoclass:: gaphas.decorators.g_async
.. autofunction:: gaphas.decorators.nonrecursive

View File

@ -34,7 +34,6 @@ import cairo
from gaphas import matrix, tree
from gaphas.connections import Connection, Connections
from gaphas.decorators import nonrecursive
from gaphas.item import Item
from gaphas.model import View
@ -232,7 +231,6 @@ class Canvas:
"""Schedule only the matrix to be updated."""
self.request_update(item)
@nonrecursive
def update_now(self, dirty_items):
"""Perform an update of the items that requested an update."""
try:

View File

@ -101,30 +101,3 @@ class g_async:
self.source(async_wrapper).attach()
return wrapper
def nonrecursive(func):
"""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
"""
m = threading.Lock()
def wrapper(*args, **kwargs):
"""Decorate function with a mutex that prohibits recursive
execution."""
if m.acquire(False):
try:
return func(*args, **kwargs)
finally:
m.release()
return wrapper