SlideShare ist ein Scribd-Unternehmen logo
1 von 8
Downloaden Sie, um offline zu lesen
Twisted
is an event-driven networking
engine written in Python and
licensed under the open source
MIT License
Montag, 6. Mai 2013
• Python
• erstes Realease am 22.10.2002
• Reactor Pattern
Montag, 6. Mai 2013
Eventloop
• nur ein Thread
• select()
• Event muss
nichtblockierend
verarbeitet werden
Montag, 6. Mai 2013
from twisted.internet import protocol, reactor
class Echo(protocol.Protocol):
def dataReceived(self, data):
self.transport.write(data)
class EchoFactory(protocol.Factory):
def buildProtocol(self, addr):
return Echo()
reactor.listenTCP(1234, EchoFactory())
reactor.run()
Montag, 6. Mai 2013
Pitfalls
Montag, 6. Mai 2013
falsch
import requests
def print_website():
r = requests.get(‘http://frog32.ch’)
print r.text
Montag, 6. Mai 2013
richtig
from twisted.web.client import getPage
def print_website():
d = getPage(‘http://frog32.ch’)
d.addCallback(on_got_website)
def on_got_website(result):
print result
Montag, 6. Mai 2013
eleganter
from twisted.web.client import getPage
from twisted.internet import defer
@defer.inlineCallbacks
def print_website():
yield data = getPage(‘http://frog32.ch’)
print data
Montag, 6. Mai 2013

Weitere ähnliche Inhalte

Was ist angesagt?

Reaktive Applikationen mit Scala, Play und Akka
Reaktive Applikationen mit Scala, Play und AkkaReaktive Applikationen mit Scala, Play und Akka
Reaktive Applikationen mit Scala, Play und AkkaMarkus Klink
 
Rex - Infrastruktur als Code
Rex - Infrastruktur als CodeRex - Infrastruktur als Code
Rex - Infrastruktur als CodeJan Gehring
 
OSDC 2013 | lxc@libvirt by Erkan Yanar
OSDC 2013 | lxc@libvirt by Erkan YanarOSDC 2013 | lxc@libvirt by Erkan Yanar
OSDC 2013 | lxc@libvirt by Erkan YanarNETWAYS
 
Hands-on Hystrix - Best Practices und Stolperfallen
Hands-on Hystrix - Best Practices und StolperfallenHands-on Hystrix - Best Practices und Stolperfallen
Hands-on Hystrix - Best Practices und Stolperfalleninovex GmbH
 
Private Cloud mit Open Source
Private Cloud mit Open SourcePrivate Cloud mit Open Source
Private Cloud mit Open SourceDaniel Schneller
 
Socket Programmierung mit IPv6
Socket Programmierung mit IPv6Socket Programmierung mit IPv6
Socket Programmierung mit IPv6Christian Kauhaus
 
SysDig Metriken zentralisieren
SysDig Metriken zentralisierenSysDig Metriken zentralisieren
SysDig Metriken zentralisiereninovex GmbH
 
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...digitalSTROM.org
 
Sich selbst verstehen – der ELK-Stack in der Praxis
Sich selbst verstehen – der ELK-Stack in der PraxisSich selbst verstehen – der ELK-Stack in der Praxis
Sich selbst verstehen – der ELK-Stack in der PraxisAlexander Papaspyrou
 
Einführung in die funktionale Programmierung mit Clojure
Einführung in die funktionale Programmierung mit ClojureEinführung in die funktionale Programmierung mit Clojure
Einführung in die funktionale Programmierung mit ClojureSascha Koch
 
Solr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax EnterpriseSolr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax EnterpriseDataStax Academy
 
Containerized End-2-End Testing - JUG Saxony Day
Containerized End-2-End Testing - JUG Saxony DayContainerized End-2-End Testing - JUG Saxony Day
Containerized End-2-End Testing - JUG Saxony DayTobias Schneck
 
Automation with Ansible
Automation with AnsibleAutomation with Ansible
Automation with AnsibleSusannSgorzaly
 
Infrastructure as Code - BaselOne 17
Infrastructure as Code - BaselOne 17Infrastructure as Code - BaselOne 17
Infrastructure as Code - BaselOne 17remigius-stalder
 

Was ist angesagt? (19)

Reaktive Applikationen mit Scala, Play und Akka
Reaktive Applikationen mit Scala, Play und AkkaReaktive Applikationen mit Scala, Play und Akka
Reaktive Applikationen mit Scala, Play und Akka
 
Rex - Infrastruktur als Code
Rex - Infrastruktur als CodeRex - Infrastruktur als Code
Rex - Infrastruktur als Code
 
Node.js Security
Node.js SecurityNode.js Security
Node.js Security
 
OSDC 2013 | lxc@libvirt by Erkan Yanar
OSDC 2013 | lxc@libvirt by Erkan YanarOSDC 2013 | lxc@libvirt by Erkan Yanar
OSDC 2013 | lxc@libvirt by Erkan Yanar
 
Hands-on Hystrix - Best Practices und Stolperfallen
Hands-on Hystrix - Best Practices und StolperfallenHands-on Hystrix - Best Practices und Stolperfallen
Hands-on Hystrix - Best Practices und Stolperfallen
 
Ceph Object Store
Ceph Object StoreCeph Object Store
Ceph Object Store
 
JavaScript Performance
JavaScript PerformanceJavaScript Performance
JavaScript Performance
 
Dockerize It - Mit apex in die amazon cloud
Dockerize It - Mit apex in die amazon cloudDockerize It - Mit apex in die amazon cloud
Dockerize It - Mit apex in die amazon cloud
 
Private Cloud mit Open Source
Private Cloud mit Open SourcePrivate Cloud mit Open Source
Private Cloud mit Open Source
 
Socket Programmierung mit IPv6
Socket Programmierung mit IPv6Socket Programmierung mit IPv6
Socket Programmierung mit IPv6
 
SysDig Metriken zentralisieren
SysDig Metriken zentralisierenSysDig Metriken zentralisieren
SysDig Metriken zentralisieren
 
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
 
Nginx
NginxNginx
Nginx
 
Sich selbst verstehen – der ELK-Stack in der Praxis
Sich selbst verstehen – der ELK-Stack in der PraxisSich selbst verstehen – der ELK-Stack in der Praxis
Sich selbst verstehen – der ELK-Stack in der Praxis
 
Einführung in die funktionale Programmierung mit Clojure
Einführung in die funktionale Programmierung mit ClojureEinführung in die funktionale Programmierung mit Clojure
Einführung in die funktionale Programmierung mit Clojure
 
Solr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax EnterpriseSolr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax Enterprise
 
Containerized End-2-End Testing - JUG Saxony Day
Containerized End-2-End Testing - JUG Saxony DayContainerized End-2-End Testing - JUG Saxony Day
Containerized End-2-End Testing - JUG Saxony Day
 
Automation with Ansible
Automation with AnsibleAutomation with Ansible
Automation with Ansible
 
Infrastructure as Code - BaselOne 17
Infrastructure as Code - BaselOne 17Infrastructure as Code - BaselOne 17
Infrastructure as Code - BaselOne 17
 

Andere mochten auch

Twisted Introduction
Twisted IntroductionTwisted Introduction
Twisted Introductioncyli
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twistedsdsern
 
Python twisted
Python twistedPython twisted
Python twistedMahendra M
 
Twisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecasesTwisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecasesSylvain Zimmer
 
Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка TwistedPython Meetup
 
Asynchronous Python with Twisted
Asynchronous Python with TwistedAsynchronous Python with Twisted
Asynchronous Python with TwistedAdam Englander
 

Andere mochten auch (9)

Twisted Introduction
Twisted IntroductionTwisted Introduction
Twisted Introduction
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twisted
 
Python twisted
Python twistedPython twisted
Python twisted
 
Twisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecasesTwisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecases
 
How we use Twisted in Launchpad
How we use Twisted in LaunchpadHow we use Twisted in Launchpad
How we use Twisted in Launchpad
 
Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка Twisted
 
TDD
TDDTDD
TDD
 
Asynchronous Python with Twisted
Asynchronous Python with TwistedAsynchronous Python with Twisted
Asynchronous Python with Twisted
 
Integration Testing in Python
Integration Testing in PythonIntegration Testing in Python
Integration Testing in Python
 

Twisted Eventloop Short Presentation