Twisted: a quick introduction

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Twisted: a quick introduction - Presentation Transcript

    1. Twisted: a quick introduction Robert Coup http://rob.coup.net.nz/
    2. What? http://twistedmatrix.com “an event-driven networking engine written in Python”
    3. Networking? • You name it, Twisted does it: TCP, UDP, Telnet, SSH, SSL, HTTP, FTP, SFTP, Gopher, XMPP, MSN, AIM, IRC, Multicast, Unix, SMTP, LDAP, POP3, NNTP, NTP, DNS...
    4. Deferreds • They’re the barrier to Twisted • Single-threaded asynchronous programming • A Deferred is a promise to call code later • Not just a Python thing
    5. twisted_deferred.py
    6. Deferreds from twisted.web.client import getPage from twisted.internet import reactor def printContents(contents): ''' This is the 'callback' function, added to the Deferred and called by it when the promised data is available ''' print \"The Deferred has called printContents with the following contents:\" print contents # Stop the Twisted event handling system -- this is usually handled # in higher level ways reactor.stop()
    7. twisted_simple.py
    8. Servers from twisted.internet.protocol import Protocol, Factory from twisted.internet import reactor class QOTD(Protocol): def connectionMade(self): self.transport.write(\"An apple a day keeps the doctor away\\r\\n\") self.transport.loseConnection() # Next lines are magic: factory = Factory() factory.protocol = QOTD # 8007 is the port you want to run under. Choose something >1024 reactor.listenTCP(8007, factory) reactor.run()
    9. Instant Messaging • uses the Twisted Words project • support for XMPP (Jabber) + AIM, ICQ, MSN, IRC, … • create a bot • Wokkel makes it easier
    10. Bot • will connect to an XMPP server • show itself as being online • have a conversation with anybody who talks to it
    11. xmppClient.py
    12. Manholes • allow access into a running application • provided by the Twisted Conch project • Telnet and/or SSH
    13. Bot Manhole • SSH & Telnet access • send message to any XMPP user • grab bot statistics
    14. xmppClientWithConsole.py
    15. How to use? • Live inspection rather than trial & error debugging • distributed apps - separate components • any networking bridges, converters, multi-purpose magic apps

    + Robert CoupRobert Coup, 6 months ago

    custom

    718 views, 0 favs, 0 embeds more stats

    A quick introduction to Python's Twisted networking more

    More info about this document

    CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

    Go to text version

    • Total Views 718
      • 718 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 16
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories