Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Twisted Logic     PyCon 2013         -   Ashwini Oruganti                  @_ashfall_
Twistedasynchronous event-driven  networking framework
Twistedasynchronous event-driven  networking framework      aka... HARD
Google Summer of Code spend the summer working on an open source project with a    mentoring organization
Endpointan interface with a single method that          takes an argument                      *               returns :a ...
Server endpoint = TCP4ServerEndpoint(reactor, 8007) endpoint.listen(Factory())Client endpoint = TCP4ClientEndpoint(reactor...
class TCP4ServerEndpoint(object):    """    Implements TCP server endpoint with an IPv4    configuration    """    ...    ...
class TCP6ServerEndpoint(object):    """    Implements TCP server endpoint with an IPv6    configuration    """    ...    ...
It’s just code.
class StandardIOEndpoint(object):    """    A Standard Input/Output endpoint    """    implements(interfaces.IStreamServer...
Moral of the story:Do not get flustered. Do not overthink.. Forget its Twisted
Moral of the story:   Read the code. Solve the problem    (write code)
There’s nothing more       boring      than the    comfort zone
TCP Client Endpoint    IPv6 addresses  Hostname Resolution
class TCP6ClientEndpoint(object):   def __init__(self, reactor, host, port,               timeout=30, bindAddress=None):  ...
def _nameResolution(self, host):    """    Resolve the hostname string into a tuple    containing the host IPv6 address.  ...
DeferredCallbacks and Errbacks Flow is not obvious Debugging is tricky
class SomeState(object):    def __init__(self):        self.values = []    def getValue(self):        return self.values.p...
def foo():   return SomeState()def bar():    state = foo()    print state.getValue()
Firing the Deferred  def foo():      s = SomeState()      s.addValue(2)      return s
It’s just code.
It’s X, when it isnt      really X
It’s full of highlycomplex concepts!
“It was created by a couple of  dudes who dropped out of  school, and a 16-year-old.  HOW HARD COULD IT BE?”
It’s foreign!
camelCase PEP8: July 5, 2001   Twisted’s codingstandard: May 2, 2001
It’s huge!
“Core can fit into a floppy          disk.”
Know what youre     doing.
<conclusion />
Twisted logic
Twisted logic
Twisted logic
Upcoming SlideShare
Loading in …5
×

Twisted logic

481 views

Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

Twisted logic

  1. 1. Twisted Logic PyCon 2013 - Ashwini Oruganti @_ashfall_
  2. 2. Twistedasynchronous event-driven networking framework
  3. 3. Twistedasynchronous event-driven networking framework aka... HARD
  4. 4. Google Summer of Code spend the summer working on an open source project with a mentoring organization
  5. 5. Endpointan interface with a single method that takes an argument * returns :a listening port / a connected protocol
  6. 6. Server endpoint = TCP4ServerEndpoint(reactor, 8007) endpoint.listen(Factory())Client endpoint = TCP4ClientEndpoint(reactor, "localhost", 8007) endpoint.connect(Factory())
  7. 7. class TCP4ServerEndpoint(object): """ Implements TCP server endpoint with an IPv4 configuration """ ... def __init__(self, reactor, port, backlog=50, interface=): ... def listen(self, protocolFactory): return defer.execute( self._reactor.listenTCP, ...)
  8. 8. class TCP6ServerEndpoint(object): """ Implements TCP server endpoint with an IPv6 configuration """ ... def __init__(self, reactor, port, backlog=50, interface=::): ... def listen(self, protocolFactory): return defer.execute( self._reactor.listenTCP, ...)
  9. 9. It’s just code.
  10. 10. class StandardIOEndpoint(object): """ A Standard Input/Output endpoint """ implements(interfaces.IStreamServerEndpoint) def __init__(self, reactor): ... def listen(self, stdioProtocolFactory): return defer.execute(stdio.StandardIO, stdioProtocolFactory.buildProtocol( PipeAddress()))
  11. 11. Moral of the story:Do not get flustered. Do not overthink.. Forget its Twisted
  12. 12. Moral of the story: Read the code. Solve the problem (write code)
  13. 13. There’s nothing more boring than the comfort zone
  14. 14. TCP Client Endpoint IPv6 addresses Hostname Resolution
  15. 15. class TCP6ClientEndpoint(object): def __init__(self, reactor, host, port, timeout=30, bindAddress=None): ... def connect(self, protocolFactory): """ Connect via TCP, once the hostname resolution is done. """ ...
  16. 16. def _nameResolution(self, host): """ Resolve the hostname string into a tuple containing the host IPv6 address. """ ...def _resolvedHostConnect(self, resolvedHost, protocolFactory): """ Connect to the server using the resolved hostname. """ ...
  17. 17. DeferredCallbacks and Errbacks Flow is not obvious Debugging is tricky
  18. 18. class SomeState(object): def __init__(self): self.values = [] def getValue(self): return self.values.pop(0) def addValue(self, value): self.values.append(value)
  19. 19. def foo(): return SomeState()def bar(): state = foo() print state.getValue()
  20. 20. Firing the Deferred def foo(): s = SomeState() s.addValue(2) return s
  21. 21. It’s just code.
  22. 22. It’s X, when it isnt really X
  23. 23. It’s full of highlycomplex concepts!
  24. 24. “It was created by a couple of dudes who dropped out of school, and a 16-year-old. HOW HARD COULD IT BE?”
  25. 25. It’s foreign!
  26. 26. camelCase PEP8: July 5, 2001 Twisted’s codingstandard: May 2, 2001
  27. 27. It’s huge!
  28. 28. “Core can fit into a floppy disk.”
  29. 29. Know what youre doing.
  30. 30. <conclusion />

×