Slide 1

Slide 1 text

The Twisted Way - Ashwini Oruganti @_ashfall_ PyCon Ireland 2013

Slide 2

Slide 2 text

Twisted asynchronous event-driven networking framework

Slide 3

Slide 3 text

Twisted asynchronous event-driven networking framework aka... HARD

Slide 4

Slide 4 text

The Need Twisted Reality: The Game Threads and Java The sadness

Slide 5

Slide 5 text

The Beginning select() asyncore and Medusa …

Slide 6

Slide 6 text

The Beginning Medusa: Unmaintained and direct socket manipulation …

Slide 7

Slide 7 text

The Beginning … Twisted

Slide 8

Slide 8 text

Programming Models Single-threaded Multi-threaded Asynchronous

Slide 9

Slide 9 text

Single-threaded time

Slide 10

Slide 10 text

Single-threaded

Slide 11

Slide 11 text

Multi-threaded time

Slide 12

Slide 12 text

Multi-threaded

Slide 13

Slide 13 text

Event-driven time

Slide 14

Slide 14 text

Event-driven

Slide 15

Slide 15 text

The Reactor Waits on and handles events abstracts away platform- specific behavior

Slide 16

Slide 16 text

Event-loop while True: timeout = time_until_next_timed_event() events = wait_for_events(timeout) events += timed_events_until(now()) for event in events: event.process()

Slide 17

Slide 17 text

“Twisted softens your brains and makes you feel like your head is actually a blender optimized for gray gloop.”

Slide 18

Slide 18 text

“It was created by a couple of dudes who dropped out of school, and a 16-year-old. HOW HARD COULD IT BE?”

Slide 19

Slide 19 text

The Box Metaphor

Slide 20

Slide 20 text

“How do I even get this thing to do anything?”

Slide 21

Slide 21 text

When you look for it, there is nothing to see. When you listen for it, there is nothing to hear. When you use it, it is inexhaustible.

Slide 22

Slide 22 text

from twisted.internet import reactor reactor.run() The World’s Largest NOP

Slide 23

Slide 23 text

“The Master does his job and then stops. He understands that the universe is forever out of control.”

Slide 24

Slide 24 text

It’s humongous!

Slide 25

Slide 25 text

“Core can fit into a floppy disk.”

Slide 26

Slide 26 text

It’s just code.

Slide 27

Slide 27 text

Know what you're doing.

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text