-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into bugfix/AY-6618_FFMPEG-thumbnail-creation-…
…issue-for-ftrack-previews
- Loading branch information
Showing
7 changed files
with
57 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,17 @@ | ||
# Deprecated file | ||
# - the file container 'WeakMethod' implementation for Python 2 which is not | ||
# needed anymore. | ||
import warnings | ||
import weakref | ||
|
||
|
||
WeakMethod = getattr(weakref, "WeakMethod", None) | ||
WeakMethod = weakref.WeakMethod | ||
|
||
if WeakMethod is None: | ||
class _WeakCallable: | ||
def __init__(self, obj, func): | ||
self.im_self = obj | ||
self.im_func = func | ||
|
||
def __call__(self, *args, **kws): | ||
if self.im_self is None: | ||
return self.im_func(*args, **kws) | ||
else: | ||
return self.im_func(self.im_self, *args, **kws) | ||
|
||
|
||
class WeakMethod: | ||
""" Wraps a function or, more importantly, a bound method in | ||
a way that allows a bound method's object to be GCed, while | ||
providing the same interface as a normal weak reference. """ | ||
|
||
def __init__(self, fn): | ||
try: | ||
self._obj = weakref.ref(fn.im_self) | ||
self._meth = fn.im_func | ||
except AttributeError: | ||
# It's not a bound method | ||
self._obj = None | ||
self._meth = fn | ||
|
||
def __call__(self): | ||
if self._dead(): | ||
return None | ||
return _WeakCallable(self._getobj(), self._meth) | ||
|
||
def _dead(self): | ||
return self._obj is not None and self._obj() is None | ||
|
||
def _getobj(self): | ||
if self._obj is None: | ||
return None | ||
return self._obj() | ||
warnings.warn( | ||
( | ||
"'ayon_core.lib.python_2_comp' is deprecated." | ||
"Please use 'weakref.WeakMethod'." | ||
), | ||
DeprecationWarning, | ||
stacklevel=2 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters