For a light (i.e. short) duration process that you want results from
to return to the user, it's fairly straightforward. Here's some code
we're using to report our current code revision in an admin dashboard:

def get_code_revision():
    import os
    x = os.popen("/usr/bin/svnversion /u/django/webcode")
    versionstring = x.readline()
    x.close()
    return versionstring.strip()

For spawning a longer running background process (as you mention
towards the end), this really isn't an appropriate mechanism. Instead
look for something where you can pass a "do this" message to another
mechanism that will do the work in the background. In our case, we
have a number of what we've terms "out of band" processing, and we use
simple tokens in the database as a quick and dirty message system. So
the view method will insert a row in the database, and a background
process will periodically poll the database for any rows to process.
It's not suitable to really high bandwidth messaging needs, but it
works nicely for us.

Alternately, you can come up with some mechanism that is more "event
like" and asynchronous.

-joe



On 5/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I've spent quite a lot of time trying to simply spawn a new process
> (by spawn I mean os.P_NOWAIT). The problem is that I cannot manage to
> get django not to halt after the execution of the process spawning
> command (the idea is that in views I want to start a background
> process that is quite time intense).
>
> I've tried os.spawnl and subprocces.Popen, neither work. Or I'm just
> too n00b in Python and Django to understand how they should be
> handled. Perhaps anybody could help me? Pleease?
>
>
> Thanks,
> Ilja
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to