Skip to content
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

Fails exporting more than 1000 records with UUIDs as PKs #6

Open
morlandi opened this issue Oct 28, 2022 · 2 comments
Open

Fails exporting more than 1000 records with UUIDs as PKs #6

morlandi opened this issue Oct 28, 2022 · 2 comments

Comments

@morlandi
Copy link
Contributor

Hello,
I'm receiving the error Object of type UUID is not JSON serializable when selecting more than 1000 records for export.

The offending code is:

request.session[session_key] =  selected

since I'm using UUID as PKs in the exported Model, instead of Integers.

As a workaround, I JSON-serialized the list before saving into the session; see PR #5

Occasionally I saw the following exception:

The request's session was deleted before the request completed. The user may have logged out in a concurrent request, for example.

which I do not explain having little experience with Django sessions; my current settings being:

SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
CACHES = {
    'default': {
        'BACKEND': 'redis_cache.RedisCache',
        'LOCATION': os.environ.get('REDIS_URL', 'redis://localhost:6379/0'),
        "KEY_PREFIX": INSTANCE_NAME,
    },
}

Thank you for attention ;)

@abidibo
Copy link
Member

abidibo commented Oct 28, 2022

Hi @morlandi , thanks for your PR, I'll merge it as soon as I can.
I don't know why you're getting this session error, I guess is related to the session being actually deleted before the request succeeds. Did you take a look here https://stackoverflow.com/questions/46982576/the-requests-session-was-deleted-before-the-request-completed-the-user-may-hav ?

@morlandi
Copy link
Contributor Author

morlandi commented Oct 28, 2022

Did you take a look here https://stackoverflow.com/questions/46982576/the-requests-session-was-deleted-before-the-request-completed-the-user-may-hav ?

Thanks; that's interesting, but doesn't apply here: a single user (me) using runserver in localhost 😉

When selecting all records, the selected list could get quite big; I tried with 100K UUIDS: while the export proceeded smoothly (👏 ), I got a significant 17MB session size.

I don't know if this is an issue to worry about; just wonder whether it's worth to delete the key after using it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants