Closed euri10 closed 2 years ago
I think I need to see the code which is rendering the functions, e.g. the template. Can you share that?
the crash happens on that line
query, query_args = render(
"select :fields from sfj_dev_lake as sfjdevlake join (select x.x as x, x.ordinality as ordinality from unnest(array[:tickers]) with ordinality as x) as r on sfjdevlake.ticker=r.x where sfjdevlake.time_stamp_source=:ts::date order by r.ordinality",
fields=select_fields(*flat_fields),
tickers=funcs.comma_sep(*flat_tickers),
ts=datetime.strptime(flat_dates[0], DTFMTLAKE).date(),
)
but only the funcs.comma_sep(*flat_tickers)
can crash it
I attached a file with the flat_tickers
list, can load it with
with open("services/sfjapi/ll.txt", "r") as fp:
flat_tickers = json.load(fp)
Here's a minimal example
from buildpg import render, funcs
flat_tickers = [f'foo_{i}' for i in range(991)]
query, query_args = render(':t', t=funcs.comma_sep(*flat_tickers))
On my M1 mac running python 3.9.9 the error happens first at 991, but that might vary but os, device, python version, etc.
I'll look into a fix.
Turns out this wasn't too hard to fix. Please try out #36, if that works for you I can release a new version fairly quickly.
thanks again for the fast release @samuelcolvin
if I do
funcs.comma_sep(*flat_tickers)
with a very long list, I get aRecursionError: maximum recursion depth exceeded while calling a Python object
I coudnt make a simple reproduction other that with the attached list.
funcs.comma_sep(*flat_tickers[:2932])
is okfuncs.comma_sep(*flat_tickers[:2933])
crashedI have the same
sys.getrecursionlimit()
set at 3000 both in container and in my host, both crash, just not exactly at the same index.Is there anything I can do except increasing that limit ?