On Thu, 5 Jul 2007, Oliver Charles wrote: > > Just to give an update, I've tried forking the view, and then turning > the child process into a daemon with a double fork, and then exiting > before it gets to the return, and letting the parent do the return, > but this is not working either... > > I'm stumped, and don't really want to have to create a specific > controller daemon (but guess I'm going to have to) > > - Olllie
Use the subprocess module: import subprocess ... script = 'python' args = (script, '/path/to/executable', ...) env = { ... } pid = subprocess.Popen(args, close_fds=True, env=env).pid t = Torrent.objects.create(pid=pid) ... Remember to store the pid for later wait()ing or you'll end up with zombies. -Simon. > > On Jul 5, 2:58 am, Oliver Charles <[EMAIL PROTECTED]> wrote: >> Hi >> >> I'm currently playing around trying to make something akin to >> TorrentFlux, using Django. TorrentFlux is a system that's PHP and it >> calls shell scripts to download torrents in the background, with a web >> interface to control them. For every torrent download, a new process >> is started, which runs with the torrent - downloading and seeding it. >> >> My system is similar, and i'm at a very proof of concept stage at the >> moment. However, I've hit a problem. I can't find a nice way to spawn >> the processes, without Django hanging as long as the process needs >> (and for 600mb torrents, that's gonna be hours, and endless if seeding >> is expected). >> >> At the moment I am doing: >> >> def start(request): >> >> p = os.spawnlp(os.P_NOWAIT, 'python', 'python', '/Users/acid/Work/ >> dTorrent/btdownloadheadless', >> '/Users/acid/Desktop/Inbox/-{mininova.org}- Professional C+ >> +.torrent') >> >> t = Torrent.objects.create(pid=p) >> >> return HttpResponse(str(p)) >> >> But this is hanging, despite the P_NOWAIT (the Torrent model does get >> created). >> >> Any ideas? > > > > -- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---