-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
E1014: Unknown error - weak object has gone away #817
Comments
We've determined this to be caused by an object being garbage collected before it's use. It's resolved by increasing resources on the worker or reducing the number of devices being processed. |
@lampwins @glennmatthews any thoughts on this? |
I tried disabling garbage collection during this job by calling gc.disable() in IntendedJob.run() before
Perhaps nornir runs in its own process and so uses its own GC, or this is not strictly related to GC, or I'm disabling it in the wrong place? |
I'm running this patch now to https://github.com/pallets/jinja/blob/main/src/jinja2/utils.py as a workaround - doesn't seem to have serious side effects (other than making the jinja cache less effective, which is better than crashing) --- jinja_utils_before.py 2025-01-14 13:06:18
+++ jinja_utils_after.py 2025-01-14 13:44:31
@@ -512,7 +512,10 @@
Raise a `KeyError` if it does not exist.
"""
with self._wlock:
- rv = self._mapping[key]
+ try:
+ rv = self._mapping[key]
+ except TypeError:
+ raise KeyError
if self._queue[-1] != key:
try:
@@ -532,13 +535,16 @@
has the highest priority then.
"""
with self._wlock:
- if key in self._mapping:
- self._remove(key)
- elif len(self._mapping) == self.capacity:
- del self._mapping[self._popleft()]
+ try:
+ if key in self._mapping:
+ self._remove(key)
+ elif len(self._mapping) == self.capacity:
+ del self._mapping[self._popleft()]
- self._append(key)
- self._mapping[key] = value
+ self._append(key)
+ self._mapping[key] = value
+ except TypeError:
+ pass
def __delitem__(self, key: t.Any) -> None:
"""Remove an item from the cache dict.
@@ -549,7 +555,7 @@
try:
self._remove(key)
- except ValueError:
+ except (ValueError, TypeError):
pass
def items(self) -> t.Iterable[t.Tuple[t.Any, t.Any]]: I still can't tell if this is a bug inside Jinja or the way Jinja is used by the nornir task |
Environment
Expected Behavior
Observed Behavior
E1014: Unknown error - weak object has gone away
Steps to Reproduce
Apologies for the lack of detail, I will attempt to update once I have more. I wanted to at least capture the error and get the issue submitted.
The text was updated successfully, but these errors were encountered: