A simple thread pool implementation, that can be used for parallel I/O.
Example usage:
>>> def takes(long=10):
... sleep(long)
...
>>> pool = Threadpool(5)
>>> for x in range(10):
... pool.add_task(takes, x)
>>> pool.wait_completion()
You can’t retrieve the return values, just wait until they finish.
Initialize pool with number of workers, that run a function with given arguments and catch all exceptions.
Add a task to the queue
Wait for completion of all the tasks in the queue
A collection of tools that ease reading and writing HTML. Currently, there’s only a improved version of python’s HTMLParser.HTMLParser, that returns the HTML untouched, so you can override specific calls to add custom behavior.
This implementation is used acrylamid.filters.acronyms, acrylamid.filters.hyphenation and more advanced in acrylamid.filters.summarize. It is quite fast, but remains an unintuitive way of working with HTML.
A more useful base HTMLParser that returns the actual HTML by default:
>>> "<b>Foo</b>" == HTMLParser("<b>Foo</b>").result
It is intended to use this class as base so you don’t make the same mistakes I did before.
This is the processed HTML.
An escaped umlaut like "ä"
Preserve HTML comments.
Everything that is not a tag shows up as data, but you can’t expect that it is always a continous sentence or word.
Append ending tag to result and pop it from the stack too.
An escaped ampersand like "&".
Something like "<br />"
Append tag to stack and write it to result.
Launch a dumb webserver as thread.
A single-threaded webserver to serve while generation.
| Parameters: |
|
|---|
“Sets kill_recieved and closes the server socket.
Two switches that enable/disable automatic demandloading of modules. Imports of the following forms will be demand-loaded:
import a, b.c
import a.b as c
from a import b,c # a will be loaded immediately
These imports will not be delayed:
from a import *
b = __import__(a)
This is dark magic, currently only used for lazy import in filters as there have been mysterious exceptions in the jinja2 templating engine when enabled for views as well.
Enable global demand-loading of modules.
Disable global demand-loading of modules.
A simple wrapper around urllib2.
Sends a HEAD request to given url but does not catch any exception.
| Parameters: |
|
|---|