If you're going to be compiling code, you almost certainly don't want to be
using subprocess for this. A view should be able to return in milliseconds.
Very few native code compilations are going to be complete in milliseconds.

What you should be doing is treating the compilation step as a compilation
task:

 1) User submits code for compilation. This creates a compilation task in
state "Pending"

 2) A second process, completely external to your web server sits waiting
for new "pending" tasks; when a new task arrives, it is taken off the
queue, and moved to a "compiling" state.

 3) The user has the ability to refresh the status of the tasks they have
submitted. This could be auto-refreshed, or left as something that the user
can hit reload to see the current state.

 4) When the compilation completes, the state moves to "Done", and the user
can see the result.

This external process is called a task queue; there are lots of ways of
managing this; two relatively easy options are RQ (a simple Redis-based
queue) and Celery (a more complete option; harder to get going, but more
reliable and configurable under heavy load).

Also - as a security warning - if you're going to be exposing the ability
to compile code on the internet, be prepared to be exploited. Compilers can
do lots of things, and you're going to be giving  permission to compile
arbitrary code to anyone who can submit a compilation task. You will need
to be *extremely* careful about how you set up the compilation tools to
make sure they are adequately sandboxed.

Yours,
Russ Magee %-)

On Sun, Mar 8, 2015 at 12:08 AM, luis zarate <luisz...@gmail.com> wrote:

> You should want to read about subprocess
>
> https://docs.python.org/3.4/library/subprocess.html
>
> Install your favorite compiler and call it with subprocess as a comand
> line program.
>
> 2015-03-07 9:01 GMT-06:00 Snehasish Sen <sen.snehasis...@gmail.com>:
>
> How can I embed a c/c++ compiler to my site which can host a programming
>> competetion
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/2a2fae63-cb65-41e1-af5c-d67d30c21eb8%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/2a2fae63-cb65-41e1-af5c-d67d30c21eb8%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> "La utopĂ­a sirve para caminar" Fernando Birri
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAG%2B5VyM2yKJDZXLnndEHn%3DoVn1siTeVOeh5YsNuh5hwan2VFLw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAG%2B5VyM2yKJDZXLnndEHn%3DoVn1siTeVOeh5YsNuh5hwan2VFLw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq84-h-6L1hO%3Dq-tt237Tnq87Xq4d2Kzcms3%2B--2RYkjCCMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to