Skip to main content

Status And License

Wait For It is distributed under an MIT-style license. It is by Ian Bicking. Questions can go to the Paste mailing list; bugs can be reported in the Paste Bug Tracker.

What It Does

Wait For It gives users a timely response even when the underlying WSGI application isn’t very timely. Wait For It does this by launching an extra thread for each incoming request. If the wrapped application responds in a timely manner (before time_limit) the response is simply passed on.

If the response doesn’t come back before the time limit, the user is given a response page that asks them to wait. The response page contains Javascript that will re-check the status of the page, and when the page is ready it will reload the page.

Applications can provide feedback to users by looking for environ['waitforit.progress'] and putting information in there. In particular "message" contains an HTML message for the user (e.g., if you want to show what step the long-running application is working on). "percent" is used for a progress bar; it should be a number from 0 to 100. The value in progress is sent via JSON, so you should use only strings (preferably unicode), integers, floats, dictionaries (with string keys) and lists.

Using It

Wrap you application like this:

from waitforit import WaitForIt

fast_app = WaitForIt(slow_app, time_limit=5, poll_time=10)

Then if slow_app takes longer than 5 seconds, a transition page is shown. The transition page checks to see if the response is done every 10 seconds. (The default values for both parameters is 10 seconds.)

In your application you can do:

def slow_app(environ, start_response):
    progress = environ.get('waitforit.progress', {})
    for i in range(100):
        progress['message'] = 'I have completed %s out of 100 tasks' % i
        progress['percent'] = i
    ... handle response ...

Also if some requests should be handled synchronously (even if they may be slow) you can indicate that with:

def slow_app(environ, start_response):
    progress = environ.get('waitforit.progress', {})
    if you_should_really_wait_for_this_to_return(environ):
        progress['synchronous'] = True
    ...

That is, setting environ['waitforit.progress']['synchronous'] = True, if done in a timely way, will keep WaitForIt from intercepting the request.

Download & Installation

You can install with easy_install WaitForIt. You can also install the most recent code from trunk with easy_install WaitForIt==dev. You can see the most recent code in the svn repository, or check it out like:

svn co http://svn.pythonpaste.org/Paste/WaitForIt/trunk WaitForIt

Example

To see a simple example, see waitforit.testapp. You can run it like python waitforit/testapp.py (or if you are using Python 2.5, python -m waitforit.testapp).

Release files for WaitForIt 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for WaitForIt 0.2
File Size Uploaded
WaitForIt-0.2.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for WaitForIt 0.2
File Interpreter ABI Platform
WaitForIt-0.2-py2.4.egg Legacy Egg format - - Details

Total release size: 21.1 kB

Release files / WaitForIt-0.2.tar.gz

Download URL WaitForIt-0.2.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
feeba8eae923a18e36546f240476efc0362033cc59b6d41f133d928370d75251
BLAKE2b-256 checksum
How to use checksums
d5912770b9d84919b2588e19e280834b03843458c62dae0fbf39de8cdc27d47d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / WaitForIt-0.2-py2.4.egg

Download URL WaitForIt-0.2-py2.4.egg
Size 13.2 kB
Tags Egg
SHA-256 checksum
How to use checksums
ff9235d51370f1e1e79039dc472c80deca674f1a13654d4615fe9a11a4cde91c
BLAKE2b-256 checksum
How to use checksums
f0240f4720908b702947c569c481652e9e6cb153049bd49f07b72cb17ad8f6a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page