Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have found that using <a href="http://uwsgi-docs.readthedocs.org/en/latest/PythonDecorators.html" rel="nofollow noreferrer">uWSGI Decorators</a> is <strong>quite</strong> simpler than using Celery if you need just run some long task in background. Think Celery is best solution for serious heavy project, and it's overhead for doing something simple.</p> <p>For start using <a href="http://uwsgi-docs.readthedocs.org/en/latest/PythonDecorators.html" rel="nofollow noreferrer">uWSGI Decorators</a> you just need to update your uWSGI config with</p> <pre><code>&lt;spooler-processes&gt;1&lt;/spooler-processes&gt; &lt;spooler&gt;/here/the/path/to/dir&lt;/spooler&gt; </code></pre> <p>write code like:</p> <pre><code>@spoolraw def long_task(arguments): try: doing something with arguments['myarg']) except Exception as e: ...something... return uwsgi.SPOOL_OK def myView(request) long_task.spool({'myarg': str(someVar)}) return render_to_response('done.html') </code></pre> <p>Than when you start view in uWSGI log appears:</p> <pre><code>[spooler] written 208 bytes to file /here/the/path/to/dir/uwsgi_spoolfile_on_hostname_31139_2_0_1359694428_441414 </code></pre> <p>and when task finished:</p> <pre><code>[spooler /here/the/path/to/dir pid: 31138] done with task uwsgi_spoolfile_on_hostname_31139_2_0_1359694428_441414 after 78 seconds </code></pre> <p>There is strange(for me) restrictions: </p> <pre><code> - spool can receive as argument only dictionary of strings, look like because it's serialize in file as strings. - spool should be created on start up so "spooled" code it should be contained in separate file which should be defined in uWSGI config as &lt;import&gt;pyFileWithSpooledCode&lt;/import&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload