0

Scenario: User loads a page, image is being generated, show loading bar, notification event sent to browser.

I am using python code to generate the image. Would it be ideal to have a web server that launches the script or embed a webserver code into the python script? Once the image is finished rendering, the client should receive a message saying it's successful and display the image.

How can this be architected to support concurrent users as well? Would simply launching the python script for each new user that navigates to the web page suffice?

Would it be overkill to have real-time web application for this scenario? Trying to decide whether simple jQuery AJAX will suffice or Socket.io should be used to have a persistent connection between server and client.

Any libraries out there that fit my needs?

2 Answers 2

1

I would recommend not spawning a new child for every request, but rather using some task queue management tool, for example I can reccomend celery.

You could for example run a threaded python webserver which would spawn one task for each request. Each client could then ask periodically (javascript/jquery) if the task is finished, and if so, server would return proper image address. Also, celery has web-callbacks which could be used in this case. (I think, I have not used this feature myself).

I would not lose time with writing some ad-hoc solution, since this is simple, easy to deploy, well documented and scales very well.

Sign up to request clarification or add additional context in comments.

2 Comments

how is celery different from github's resque?
It is designed for python; I am not familiar with resque, but from the spec, I think it is similar.
1

I personally love Socket.IO and I would to it with it. Because it would be simpler a way. But that may be a bit too much work to set up just for that. Especially since it is not that simple in Python from what I heard compare to node where it really is about 10 lines server side.

Without Socket.IO could do a long polling to get the status of the image processing, and get the url at the end, of the image in base64 if that is what you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.