Skip to content

Commit

Permalink
SACGF/variantgrid_com#86 - variantgrid.com crash on new VM - use iter…
Browse files Browse the repository at this point in the history
…ator
  • Loading branch information
davmlaw committed Sep 11, 2024
1 parent 3951d51 commit 961f24b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/jqgrid/jqgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class JqGrid:
colmodel_overrides = {} # Class member, do not modify in instances!

def __init__(self):
# Use for enormous querysets (eg downloads) to reduce RAM usage
self.use_iterator_if_no_pagination = False
self.extra_config = {}
self._overrides = deepcopy(self.colmodel_overrides)
if not self.fields:
Expand Down Expand Up @@ -306,6 +308,9 @@ def get_paginate_by(self, request):
def paginate_items(self, request, items):
paginate_by = self.get_paginate_by(request)
if not paginate_by:
if self.use_iterator_if_no_pagination:
items = items.iterator()

return None, None, items

paginator = Paginator(items, paginate_by,
Expand Down
1 change: 1 addition & 0 deletions snpdb/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def __init__(self, *args, **kwargs):
self._count = None
self.queryset_is_sorted = False
self.sort_by_contig_and_position = False
self.use_iterator_if_no_pagination = True # Paginator disabled on downloads

def _get_standard_overrides(self, af_show_in_percent):
overrides = {
Expand Down

0 comments on commit 961f24b

Please sign in to comment.