Your SlideShare is downloading. ×
0
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Twisted logic
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Twisted logic

172

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
172
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Twisted Logic PyCon 2013 - Ashwini Oruganti @_ashfall_
  • 2. Twistedasynchronous event-driven networking framework
  • 3. Twistedasynchronous event-driven networking framework aka... HARD
  • 4. Google Summer of Code spend the summer working on an open source project with a mentoring organization
  • 5. Endpointan interface with a single method that takes an argument * returns :a listening port / a connected protocol
  • 6. Server endpoint = TCP4ServerEndpoint(reactor, 8007) endpoint.listen(Factory())Client endpoint = TCP4ClientEndpoint(reactor, "localhost", 8007) endpoint.connect(Factory())
  • 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. 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. It’s just code.
  • 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. Moral of the story:Do not get flustered. Do not overthink.. Forget its Twisted
  • 12. Moral of the story: Read the code. Solve the problem (write code)
  • 13. There’s nothing more boring than the comfort zone
  • 14. TCP Client Endpoint IPv6 addresses Hostname Resolution
  • 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. 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. DeferredCallbacks and Errbacks Flow is not obvious Debugging is tricky
  • 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. def foo(): return SomeState()def bar(): state = foo() print state.getValue()
  • 20. Firing the Deferred def foo(): s = SomeState() s.addValue(2) return s
  • 21. It’s just code.
  • 22. It’s X, when it isnt really X
  • 23. It’s full of highlycomplex concepts!
  • 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. It’s foreign!
  • 26. camelCase PEP8: July 5, 2001 Twisted’s codingstandard: May 2, 2001
  • 27. It’s huge!
  • 28. “Core can fit into a floppy disk.”
  • 29. Know what youre doing.
  • 30. <conclusion />

×