Skip to content

Commit

Permalink
Remove nonrecursive decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
amolenaar committed Aug 18, 2024
1 parent ad7e00b commit 060760f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 31 deletions.
2 changes: 0 additions & 2 deletions docs/decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ Decorators
==========

.. autoclass:: gaphas.decorators.g_async

.. autofunction:: gaphas.decorators.nonrecursive
2 changes: 0 additions & 2 deletions gaphas/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

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

Expand Down Expand Up @@ -232,7 +231,6 @@ def request_matrix_update(self, item):
"""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:
Expand Down
27 changes: 0 additions & 27 deletions gaphas/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,3 @@ def async_wrapper(*_args):
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

0 comments on commit 060760f

Please sign in to comment.