• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Deferred Gratification
 

Deferred Gratification

on

  • 3,112 views

Slides from a talk titled "Deferred Gratification" by Terry Jones at EuroPython 2010 in Birmingham

Slides from a talk titled "Deferred Gratification" by Terry Jones at EuroPython 2010 in Birmingham

Statistics

Views

Total Views
3,112
Views on SlideShare
3,109
Embed Views
3

Actions

Likes
3
Downloads
19
Comments
0

1 Embed 3

https://twitter.com 3

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />

Deferred Gratification Deferred Gratification Presentation Transcript

  • Deferred Gratification Patterns of asynchronous flow of control with Twisted deferreds Terry Jones terry@fluidinfo.com @terrycojones
  • Not an intro talk. Sorry! • Assume you understand Deferreds • Assume you understand async
  • Read defer.py • Lots of people don’t • Much of it is beautiful • Deferreds seem cryptic • They’re are actually very simple
  • Building blocks Simple functions that help with deferreds • succeed • fail • maybeDeferred Classes that build on simple deferreds • DeferredList • DeferredQueue • DeferredSemaphore • DeferredLock
  • Deferreds let you replace synchronous data structures with elegant asynchrnous equivalents
  • Some of our classes http://jon.es/other/europython-2010-deferreds.tar.bz2 • tee • RetryingCall • DeferredPooler } • ControllableDeferred • DeferredPool rdq.py • ResizableDispatchQueue
  • DeferredPooler client client server whatever client
  • DeferredPooler client fe tc h( x, y) client server whatever client
  • DeferredPooler client fe tc h( x, y) fetch(x,y) client server whatever client
  • DeferredPooler client fe tc h( x, y) fetch(x,y) fetch(x,y) client server whatever client
  • DeferredPooler client fe tc h( x, y) fetch(x,y) fetch(x,y) client server whatever , y) ( x ch f et client
  • DeferredPooler client fe tc h( x, y) fetch(x,y) fetch(x,y) client server whatever result , y) ( x ch f et client
  • DeferredPooler client fe tc re h( su x, lt y) fetch(x,y) fetch(x,y) client server whatever result result , y) x h( tc fe ult r es client
  • Normal Deferred 1 d = someFunc(arg1,arg2) cb1 cb2 cb3 2 d.addCallback() cb1 cb2 cb3 cb4 cb5 3 # Hope d fires!
  • Controllable Deferred 1 d = ControllableDeferred(someFunc,arg1,arg2) cb1 cb2 cb3 2 d.addCallback() cb1 cb2 cb3 ? cb4 cb5 3 # If call to someFunc fires, call d. # Allow caller to call d.cancel
  • RetryingCall Replace something like this d = getPage(url) With this r = RetryingCall(getPage, url) d = r.start()
  • Resizable Dispatch Queue Tickery adder RDQ pending WWW put put a b c d underway Twitter e doWork f FluidDB call g admin pause, resume, stop, size, widen, narrow, underway, cancel