F5F Stay Refreshed Software General Software The question asks about understanding what a "Weak Reference" is and its usage context.

The question asks about understanding what a "Weak Reference" is and its usage context.

The question asks about understanding what a "Weak Reference" is and its usage context.

K
Koollojoe
Posting Freak
830
10-07-2023, 02:20 PM
#1
The issue arises because you're trying to use a string variable `myTemplate` that hasn't been properly defined or loaded yet. To resolve this, ensure the template file is correctly generated and imported before calling `get_template`. Also, verify that the environment is set up correctly and the template rendering process completes without errors.
K
Koollojoe
10-07-2023, 02:20 PM #1

The issue arises because you're trying to use a string variable `myTemplate` that hasn't been properly defined or loaded yet. To resolve this, ensure the template file is correctly generated and imported before calling `get_template`. Also, verify that the environment is set up correctly and the template rendering process completes without errors.

R
RavenRavine
Member
197
10-13-2023, 12:10 AM
#2
FYI - Start here:
https://docs.python.org/3/library/weakref.html
https://www.tutorialspoint.com/pyth...running,object from getting garbage collected
.
https://link.springer.com/chapter/10.100...-40336-1_4
Review the links then examine your code again.
Uncertain about the full context but it might relate to "garbage collection".
That said, I’ll rely on the Community’s Python users for this.
R
RavenRavine
10-13-2023, 12:10 AM #2

FYI - Start here:
https://docs.python.org/3/library/weakref.html
https://www.tutorialspoint.com/pyth...running,object from getting garbage collected
.
https://link.springer.com/chapter/10.100...-40336-1_4
Review the links then examine your code again.
Uncertain about the full context but it might relate to "garbage collection".
That said, I’ll rely on the Community’s Python users for this.

G
gemoore
Junior Member
46
10-20-2023, 01:23 AM
#3
My assumption is this line might be the issue
Python:
env = Environment(loader='file')
All other examples and users seem to pass an instance of a FileSystemLoader or PackageLoader from the jninja2 package. Otherwise, check the documentation for expectations.
The error appears to point to get_template calling weakref.ref. At least for CPython, you can't create weak references for strings because built-in types don’t support that mechanism to save overhead.
G
gemoore
10-20-2023, 01:23 AM #3

My assumption is this line might be the issue
Python:
env = Environment(loader='file')
All other examples and users seem to pass an instance of a FileSystemLoader or PackageLoader from the jninja2 package. Otherwise, check the documentation for expectations.
The error appears to point to get_template calling weakref.ref. At least for CPython, you can't create weak references for strings because built-in types don’t support that mechanism to save overhead.