<s>
Twisted	O
is	O
an	O
event-driven	B-Application
network	B-Operating_System
programming	I-Operating_System
framework	B-Architecture
written	O
in	O
Python	B-Language
and	O
licensed	O
under	O
the	B-License
MIT	I-License
License	I-License
.	O
</s>
<s>
Twisted	O
projects	O
variously	O
support	O
TCP	B-Protocol
,	O
UDP	B-Protocol
,	O
SSL/TLS	B-Protocol
,	O
IP	B-Protocol
multicast	I-Protocol
,	O
Unix	B-Protocol
domain	I-Protocol
sockets	I-Protocol
,	O
many	O
protocols	O
(	O
including	O
HTTP	B-Protocol
,	O
XMPP	B-Protocol
,	O
NNTP	B-Protocol
,	O
IMAP	B-Protocol
,	O
SSH	B-Protocol
,	O
IRC	B-Protocol
,	O
FTP	B-Protocol
,	O
and	O
others	O
)	O
,	O
and	O
much	O
more	O
.	O
</s>
<s>
Twisted	O
is	O
based	O
on	O
the	O
event-driven	B-Application
programming	I-Application
paradigm	O
,	O
which	O
means	O
that	O
users	O
of	O
Twisted	O
write	O
short	O
callbacks	O
which	O
are	O
called	O
by	O
the	O
framework	B-Architecture
.	O
</s>
<s>
Twisted	O
is	O
designed	O
for	O
complete	O
separation	O
between	O
logical	O
protocols	O
(	O
usually	O
relying	O
on	O
stream-based	O
connection	O
semantics	O
,	O
such	O
as	O
HTTP	B-Protocol
or	O
POP3	B-Protocol
)	O
and	O
physical	O
transport	O
layers	O
supporting	O
such	O
stream-based	O
semantics	O
(	O
such	O
as	O
files	O
,	O
sockets	B-Protocol
or	O
SSL	O
libraries	O
)	O
.	O
</s>
<s>
Naturally	O
,	O
such	O
protocol	O
code	O
will	O
fail	O
(	O
raise	B-General_Concept
an	I-General_Concept
exception	I-General_Concept
)	O
if	O
the	O
transport	O
layer	O
does	O
not	O
support	O
such	O
semantics	O
.	O
</s>
<s>
Central	O
to	O
the	O
Twisted	O
application	O
model	O
is	O
the	O
concept	O
of	O
a	O
deferred	O
(	O
elsewhere	O
called	O
a	O
future	B-Operating_System
)	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
a	O
deferred	O
returns	O
a	O
string	O
from	O
a	O
remote	O
peer	O
containing	O
an	O
IP	B-Protocol
address	I-Protocol
in	O
quad	O
format	O
,	O
a	O
callback	O
can	O
be	O
attached	O
to	O
translate	O
it	O
into	O
a	O
32-bit	O
number	O
.	O
</s>
<s>
This	O
,	O
and	O
the	O
related	O
ability	O
to	O
define	O
"	O
errbacks	O
"	O
(	O
callbacks	O
which	O
are	O
called	O
as	O
error	B-General_Concept
handlers	I-General_Concept
)	O
,	O
allows	O
code	O
to	O
specify	O
in	O
advance	O
what	O
to	O
do	O
when	O
an	O
asynchronous	O
event	O
occurs	O
,	O
without	O
stopping	O
to	O
wait	O
for	O
the	O
event	O
.	O
</s>
<s>
In	O
non-event-driven	O
systems	O
,	O
for	O
example	O
using	O
threads	B-Operating_System
,	O
the	O
operating	O
system	O
incurs	O
premature	O
and	O
additional	O
overhead	O
organizing	O
threads	B-Operating_System
each	O
time	O
a	O
blocking	O
call	O
is	O
made	O
.	O
</s>
<s>
Twisted	O
supports	O
an	O
abstraction	O
over	O
raw	O
threads	B-Operating_System
—	O
using	O
a	O
thread	B-Operating_System
as	O
a	O
deferred	O
source	O
.	O
</s>
<s>
Thus	O
,	O
a	O
deferred	O
is	O
returned	O
immediately	O
,	O
which	O
will	O
receive	O
a	O
value	O
when	O
the	O
thread	B-Operating_System
finishes	O
.	O
</s>
<s>
Callbacks	O
can	O
be	O
attached	O
which	O
will	O
run	O
in	O
the	O
main	O
thread	B-Operating_System
,	O
thus	O
alleviating	O
the	O
need	O
for	O
complex	O
locking	O
solutions	O
.	O
</s>
<s>
The	O
database	O
call	O
itself	O
happens	O
on	O
a	O
foreign	O
thread	B-Operating_System
,	O
but	O
the	O
analysis	O
of	O
the	O
result	O
happens	O
in	O
the	O
main	O
thread	B-Operating_System
.	O
</s>
<s>
Twisted	O
can	O
integrate	O
with	O
foreign	O
event	O
loops	O
,	O
such	O
as	O
those	O
of	O
GTK+	B-Application
,	O
Qt	B-Language
and	O
Cocoa	B-Operating_System
(	O
through	O
PyObjC	B-Operating_System
)	O
.	O
</s>
<s>
This	O
allows	O
using	O
Twisted	O
as	O
the	O
network	O
layer	O
in	O
graphical	B-Application
user	I-Application
interface	I-Application
(	O
GUI	B-Application
)	O
programs	O
,	O
using	O
all	O
of	O
its	O
libraries	O
without	O
adding	O
a	O
thread-per-socket	O
overhead	O
,	O
as	O
using	O
Python	B-Language
's	O
native	O
library	O
would	O
.	O
</s>
<s>
A	O
full-fledged	O
web	O
server	O
can	O
be	O
integrated	O
in-process	O
with	O
a	O
GUI	B-Application
program	O
using	O
this	O
model	O
,	O
for	O
example	O
.	O
</s>
<s>
The	O
BuildBot	B-Application
continuous-integration	O
system	O
relies	O
on	O
Twisted	O
for	O
client/server	O
communication	O
.	O
</s>
<s>
ITA	B-Application
Software	I-Application
has	O
developed	O
an	O
airline-reservation	O
system	O
for	O
Air	O
Canada	O
that	O
uses	O
Twisted	O
extensively	O
.	O
</s>
<s>
SageMath	B-Application
,	O
an	O
open-source	O
alternative	O
to	O
Mathematica	B-Language
,	O
Maple	B-Language
,	O
Magma	B-General_Concept
,	O
MATLAB	B-Language
,	O
has	O
a	O
web-based	O
interface	O
,	O
SageMath	B-Application
notebook	O
,	O
that	O
runs	O
on	O
a	O
Twisted	O
server	O
.	O
</s>
<s>
The	O
original	O
version	O
of	O
social	O
networking	B-Operating_System
and	O
microblogging	O
site	O
Jaiku	B-Protocol
used	O
Twisted	O
.	O
</s>
<s>
Fluidinfo	B-Language
,	O
an	O
online	O
cloud	O
data-store	O
,	O
uses	O
Twisted	O
extensively	O
for	O
internal	O
RPC	O
(	O
partly	O
in	O
combination	O
with	O
Thrift	B-Protocol
and	O
AMQP	B-Operating_System
)	O
,	O
for	O
its	O
internal	O
services	O
,	O
and	O
for	O
external	O
APIs	O
.	O
</s>
<s>
The	O
file-hosting	O
service	O
Ubuntu	B-Language
One	I-Language
used	O
Twisted	O
.	O
</s>
<s>
Tor2web	B-Application
,	O
an	O
HTTP	B-Protocol
proxy	O
for	O
Tor	O
Hidden	O
Services	O
(	O
HS	O
)	O
,	O
uses	O
Twisted	O
.	O
</s>
<s>
GlobaLeaks	B-Language
,	O
an	O
open-source	O
whistleblowing	O
framework	B-Architecture
,	O
uses	O
Twisted	O
.	O
</s>
<s>
It	O
now	O
has	O
been	O
rewritten	O
using	O
Node.js	B-Language
.	O
</s>
<s>
Twilio	B-General_Concept
,	O
a	O
cloud	O
telephony	O
provider	O
,	O
uses	O
Twisted	O
.	O
</s>
<s>
qwebirc	O
,	O
a	O
web-based	O
IRC	B-Protocol
client	O
,	O
uses	O
Twisted	O
.	O
</s>
<s>
Zenoss	B-Protocol
Core	I-Protocol
,	O
a	O
network	O
management	O
platform	O
,	O
uses	O
Twisted	O
for	O
many	O
internal	O
and	O
collection	O
daemons	O
.	O
</s>
<s>
Scrapy	B-Protocol
,	O
a	O
web	O
crawler	O
based	O
on	O
Twisted	O
.	O
</s>
<s>
Tahoe-LAFS	B-General_Concept
,	O
a	O
distributed	O
data	O
store	O
and	O
distributed	O
file	O
system	O
.	O
</s>
<s>
Deluge	B-Language
,	O
a	O
highly	O
modular	O
BitTorrent	B-Protocol
client	O
,	O
uses	O
Twisted	O
.	O
</s>
<s>
Magic	O
Wormhole	O
,	O
a	O
secure	O
file	O
transfer	O
tool	O
using	O
PAKE	B-Protocol
.	O
</s>
