Twisted (software)

Twisted (software)

Infobox Software
name = Twisted



caption =
collapsible =
author = Glyph Lefkowitz
developer = Community
released = 22 October 2002 [cite mailinglist|last=Shtull-Trauring|first=Itamar|title=ANN: Twisted 1.0|date=2002-10-22|accessdate=2008-08-14|mailinglist=twisted-python|url=http://twistedmatrix.com/pipermail/twisted-python/2002-October/002049.html]
latest release version = 8.1.0
latest release date = release date and age|2008|05|18
latest preview version =
latest preview date =
frequently updated =
programming language = Python
operating system =
platform =
size =
language =
status = Mature
genre = Event-driven networking
license = MIT License
website = http://twistedmatrix.com/

Twisted is an event-driven network programming framework written in Python and licensed under the MIT License.

Twisted projects variously support TCP, UDP, SSL/TLS, IP Multicast, Unix domain sockets, a large number of protocols (including HTTP, NNTP, IMAP, SSH, IRC, FTP, and others), and much more. Twisted is based on the event-driven programming paradigm, which means that users of Twisted write short callbacks which are called by the framework.

Core ideas

Separation of protocols and transports

Twisted is designed for complete separation between logical protocols (usually relying on stream-based connection semantics, such as HTTP or POP3) and physical transport layers supporting such stream-based semantics (such as files, sockets or SSL libraries). Connection between a logical protocol and a transport layer happens at the last possible moment—just before information is passed into the logical protocol instance. The logical protocol is informed of the transport layer instance, and can use it to send messages back and to check for the peer's identity. Note that it is still possible, in protocol code, to deeply query the transport layer on transport issues (such as checking a client-side SSL certificate). Naturally, such protocol code will fail (raise an exception) if the transport layer does not support such semantics.

Deferreds

Central to the Twisted application model is the concept of a "deferred" (elsewhere called a "future"). A deferred is a value which has not been computed yet, for example because it needs data from a remote peer. Deferreds can be passed around, just like regular objects, but cannot be asked for their value. Each deferred supports a callback chain. When the deferred gets the value, it is transferred through the callback chain, with the result of each callback being the input for the next one. This allows operating on the values of a deferred without knowing what they are. For example, if a deferred returns a string from a remote peer containing an IP address in quad format, a callback can be attached to translate it into a 32-bit number. Any user of the deferred can now treat it is as a deferred returning a 32-bit number. This, and the related ability to define "errbacks" (callbacks which are called as error handlers), allows code which looks as though it is serial, while still maintaining the event-driven abstraction.

Thread support

Twisted supports an abstraction over raw threads—using a thread as a deferred source. Thus, a deferred is returned immediately, which will receive a value when the thread finishes. Callbacks can be attached which will run in the main thread, thus alleviating the need for complex locking solutions. A prime example of such usage, which comes from Twisted's support libraries, is using this model to call into databases. The database call itself happens on a foreign thread, but the analysis of the result happens in the main thread.

Foreign loop support

Twisted can integrate with foreign event loops, such as those of GTK+, Qt and Cocoa (through PyObjC). This allows using Twisted as the networking support layer in GUI programs, using all of its libraries without adding a thread-per-socket overhead, as using Python's native library would. A full-fledged web server can be integrated in-process with a GUI program using this model, for example.

Applications using Twisted

An example of a popular implementation of Twisted could be Jaiku. A new airline reservation written by ITA Software for Air Canada uses Twisted extensively [ [http://www.eweek.com/c/a/Application-Development/Python-Slithers-into-Systems/1/ Page 2 - Python Slithers into Systems ] ] .

See also

* Perl Object Environment, a comparable framework for the Perl programming language
* Twisted Lore, a documentation generator developed by the Twisted team.

References

External links

* [http://twistedmatrix.com/ Twisted Matrix Labs HomePage]


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Twisted (software) — Twisted Desarrollador Glyph Lefkowitz, Community http://twistedmatrix.com/ …   Wikipedia Español

  • Twisted — may refer to: Music Industry: * Twisted Records (UK), a UK based record label specializing in psychedelic trance * Twisted Records (US), an American electronic music record label Works: * Twisted (Del Amitri album) * Twisted (Hallucinogen album) …   Wikipedia

  • Twisted Metal (série) — Twisted Metal est une série de jeux vidéo de combat motorisé sur PlayStation, PlayStation 2 et PlayStation Portable (un épisode pour PlayStation 3 est en cours de développement). La série est publiée par Sony Computer Entertainment ; elle a… …   Wikipédia en Français

  • Twisted Metal: Black — Éditeur Sony Computer Entertainment Développeur Incognito Entertainment Concepteur David Jaffe Scott Campbell Date de sortie TM:B …   Wikipédia en Français

  • Twisted Metal: Black Online — Twisted Metal: Black Twisted Metal: Black Éditeur Sony Computer Entertainment Développeur Incognito Entertainment Concepteur David Jaffe Scott Campbell Date de sortie TM:B …   Wikipédia en Français

  • Twisted — Тип фрей …   Википедия

  • The Twisted Tales of Spike McFang — Infobox VG title = The Twisted Tales of Spike McFang developer = Red Company publisher = Naxat Soft (JP), Bullet Proof Software (NA) designer = released = JPN 1993 NA 1994 genre = Action RPG modes = Single player ratings = platforms = SNES media …   Wikipedia

  • The Twisted Tales of Felix the Cat — Series Title Card Genre Animation Series Comedy Fantasy Created by …   Wikipedia

  • Microsoft Software Assurance — (SA) is a Microsoft maintenance program aimed at business users who use Microsoft Windows, Microsoft Office, and other server and desktop applications. The core premise behind SA is to give users the ability to spread their payments for the… …   Wikipedia

  • List of Microsoft software applications — Not to be confused with List of Microsoft Windows components. The following is a list of notable Microsoft software applications. Contents 1 Development tools 2 Digital media authoring 3 Internet 4 …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”