Starting an external, independent process from a script

H

Henrik Lied

Hi there!

I'm trying to create a video uploading service (just to learn). The
system is mostly based on Django, but the question I'm looking an
answer for is more related to Python.

So, the user gets to upload a video file. This can either be a mpg,
avi or mp4-file. When the file is saved to its location, I want to
convert it to FLA (Flash Video). I'm currently using Mplayers
Mencoder, and this works great. The Mencoder is retrieved through
running os.system("mencoder variables here")

The problem with this is that the user has to wait until the movie is
done encoding until he can go around with his business. I don't look
upon this as ideal.

So - I want to spawn a new system process. I need some good pointers
on how to do this right.

Any input? :)

Thanks a lot in advance!
 
T

Thinker

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Henrik said:
Hi there!


So - I want to spawn a new system process. I need some good
pointers on how to do this right.

Any input? :)

Thanks a lot in advance!
You can try os.spawnl().
The url is http://docs.python.org/lib/os-process.html


- --
Thinker Li - (e-mail address removed) (e-mail address removed)
http://heaven.branda.to/~thinker/GinGin_CGI.py
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF9jFe1LDUVnWfY8gRArO/AKDaJaHfrAluc0euEqPn/NN2J2tXsgCgye/D
ujNCylOGx3P/yC0UZc5oXHc=
=yRuY
-----END PGP SIGNATURE-----
 
H

Henrik Lied

I've tried os.spawnv and os.spawn, but these give no error and no
result.


Henrik Lied skreiv:
 
D

Dennis Lee Bieber

On 13 Mar 2007 02:45:28 -0700, "Henrik Lied" <[email protected]>
declaimed the following in comp.lang.python:

Reordered to make chronological sense...
Henrik Lied skreiv:
I've tried os.spawnv and os.spawn, but these give no error and no
result.
You have conflicting requirements...

On the one hand you want to spawn a separate process so the initial
connection can be terminated...

On the other, you want to hang around to get a success status from
the spawned process (especially if you want to report that status to the
client)... This requires the initial connection stay active... HTTP is a
"pull" technology -- everything is controlled by requests /from/ the
browser; you can't push status asynchronously to the client after
closing a transaction.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
G

Gabriel Genellina

En Tue, 13 Mar 2007 06:57:33 -0300, rishi pathak
You can do something like this:
pid = os.fork()

I don't think it's a good idea, the running process is Django, not a
script.

To the OP: I think the question *is* a Django question. You could launch
the external process, finish the current request and redirect to another
location; in that page you set a refresh to itself, and show the current
status "somehow" depending on how your external process can report its
progress. The details on how to do that, or even if that way is a good
approach at all, depend on Django.
 
S

skam

I use ffmpeg instead of mencoder, calling it using os.popen(). You can
also use the "commands" module, but I prefer the first one.

Bye,
Massimo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top