How to start background process in Pylons?

I am trying to write an application that will allow the user to start a rather lengthy process (5-30 seconds). Then it should allow the user to verify the output of the process as it is created. Logging out will only be necessary for the current user session, so nothing needs to be stored for long. I have two questions regarding how to do this, taking advantage of the Pylons system:

  • What is the best way to start a background process, for example using a Pylons controller?

  • What is the best way to return the result of a background process to a user? (Should I store the output in a database, in session data, etc.?)

Edit: The problem is that if I run the command using the subprocessin the controller, the controller waits for the subprocess to complete before continuing, showing the user a blank page that just loads until the process completes. I want to be able to redirect the user to the status page immediately after starting the subprocess, allowing him to execute on his own.

+3
source share
2 answers

( , HTTP), daemonize. Pylons ( ), . , .

- AJAX- "" . tmp (cPickle ) -.

daemon python: http://code.activestate.com/recipes/278731/

+6

, . ( ) :

  • .
  • , . (*).
  • /tmp/project/ID
  • , URL- /job/ID /job?id=ID. , , .

(*) , , , pylons , .

+1

Source: https://habr.com/ru/post/1713534/


All Articles