Jack, >From what I understand it looks like a conflict of uniquely named files when they are generated simultaneously. Could you resolve this by creating a folder named from the session_id, with the file inside of that. So that if two users request the same file, there will never be a conflict, as the unique file will be created in both folders.
[user_1_session_id]/entry123.jpeg [user_2_session_id]/entry123.jpeg Though, this might seem like a fix, but the issue may be more fundamental than file names. Let me know what you think. Regards, James On Thu, Oct 17, 2019 at 4:23 PM Jack Sundberg <jacksundberg...@gmail.com> wrote: > Yes, I tried getting the idea across in layman terms, as I hope this helps > discussion of the issue -- and then I can later translate the solution into > django implementation. > > I avoided the full process in my original post for clarity. I used the > *.jpeg file as an illustrative example, when I'm actually generating *.gltf > and *.bin files. These files are typically a couple hundred KB in size, but > I will have thousands of them (millions as I add to my database). These > files are used in coordination with Verge3D - an app built on top of > Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which is > a python-based program that my scripts are written in. Running of these > scripts are certainly cpu intensive; however I am going to get around this > by using an <iframe> of this Verge3D request. > > So to be more specific, my app does the following: > - the url mapping pulls a database entry > - the app serves the proper html template with an <iframe> embedded in > it. It displays a loading screen while the 3D model is created backend. > - the <iframe> calls a separate app using the identical data entry > - using the data entry, static files are created from the data (Blender > script creates a *.gltf and *.bin) > - the app serves the html template with the generated static files > embedded inside the <iframe> > > Is this helpful? Also thank you for the quick response. I really > appreciate the help. > > -Jack > > > On Thursday, October 17, 2019 at 10:56:56 AM UTC-4, vineet daniel wrote: >> >> This problem can happen with any stack and shouldn't be considered as >> django specific. What you are looking for is a solution in a layman >> terms.which then can be translated to django implementation. >> >> Before that i would like to know image size and kind of image that you >> create. Is it some qr code or what? >> >> Please note that working with images on the fly is always a cpu intensive >> operation. Ill can come up with something once you share the details with >> me. >> >> On Thu, 17 Oct 2019, 20:00 Jack Sundberg, <jacksun...@gmail.com> wrote: >> >>> Hi all, >>> >>> I am currently writing an app that generates static files before serving >>> them, and I could use some input! Here's a step-by-step example of how the >>> app is setup: >>> >>> - the url mapping pulls a database entry >>> - using the data entry, static files are created from the data (for >>> example, a *.jpeg or a *.gltf) >>> - the app serves the html template with the generated static files >>> embedded (for example, via an <img> tag) >>> >>> The issue comes with the creation of the unique static files. I can have >>> the app create a file in the static folder, send it off, then delete the >>> file to ready for the next request -- but the webpage will run into issues >>> if multiple requests are made at the same time. If two people request the >>> same url at the same time, the app will fail because both requests are >>> trying to create/serve/delete an identical file (i.e. entry123.jpeg) at the >>> same time. Trying to mess with the filename to avoid this won't work here >>> either (i.e. naming entry123.01.jpeg, entry123.02.jpeg, entry123.03.jpeg, >>> ...). >>> >>> I can think of two solutions, but they both are things I'd like to avoid: >>> 1. have the files premade and stored -- I want to avoid this because of >>> the massive filesize required for all these files >>> 2. have the static files generated in a user-specific directory -- I >>> want to avoid this because I'd rather not have registered users on my >>> website >>> >>> Is there another solution to this? I'm still relatively new with Django, >>> so there might be something simple I'm missing. >>> >>> -Jack >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/190637d2-bd9b-499a-a122-1dc7adf2aca5%40googlegroups.com >>> <https://groups.google.com/d/msgid/django-users/190637d2-bd9b-499a-a122-1dc7adf2aca5%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/317c4ce6-5378-4e59-920e-c0fdcacd453a%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/317c4ce6-5378-4e59-920e-c0fdcacd453a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOnWGOKBmsQ1ZZa81NyKkePQWc77xf-jym%2BDA97rpO2%2BbtYFgw%40mail.gmail.com.