agile.open.connected
Celery And The Social Networks
5 Things I Have Learned During
Earthquake Hackathon Andrew Mleczko
Andrew Mleczko
Python Dev
RedTurtle - Italy - Poland
amleczko@redturtle.it
@amleczko
www.redturtle.it
Andrew Mleczko
May, 20th - the earthquake
the earthquake
the earthquake
the earthquake
this is not “parmesan”
this is real italian PARMIGIANO
;-D
re-start, do it fast!
and the real needs
the virtual idea
focus on storytelling
keep attention alive
online resources
newspapers
radio
television
EARTHQUAKE 20/5
first idea 24/5engage stakeholders
collect specs 28/5
get the server
placeholder page 27/5
design layout 4/6
hackaton 11-14/6
find companies
GOLIVE 26/6
36 days from event
facciamoadesso.it was born ;-)
simply use
social networks
but...
Speed
Rate Limits
Stability
Celery can fix
all off it!
view from the top
The website architecture
Notification App (REST)
website
stories
ecommerce
companies
products
news
SMS Social
Networks
email
github.com/RedTurtle/
restarter.buildout
+
companies sell products
company profile
the product
book it!
The website architecture
Notification App (REST)
website
stories
ecommerce
companies
products
news
SMS Social
Networks
email
github.com/RedTurtle/
restarter.buildout
+
how to organize tasks?
how to organize tasks?
small
atomic
minimal state
how to organize tasks?
@task
def post_on_wall(facebook_id, message):
    params = {}
    params['id'] = facebook_id
    params['message'] = message
    response = requests.post(url, params=params)
how to organize tasks?
@task
def send_sms(login, password, message, phone):
    payload = {'login': login,
               'password': password,
               'phone': phone,
               'body' : message }
    try:
        r = requests.get('%s/send' % GATEWAY,
params=payload,
timeout=TIMEOUT)
    except requests.exceptions.Timeout as e:
send_sms.retry(e, countdown=3)
rate limits
rate limits
# make sure to not hit 3rd party limits
@task(rate_limit=’1/m’)
def send_sms(login, password, message, phone):
...
rate limits
# make sure we will never spam our wall
@task(rate_limit=’5/h’)
def post_on_wall(facebook_id, message):
    params = {}
    params['id'] = facebook_id
    params['message'] = message
    response = requests.post(url, params=params)
rate limits gotchas
➡ Fails on worker daemon restart
➡ Doesn’t work with multiple worker daemons
➡ External rate limits are based on many factors:
➡ who’s asking
➡ public/private info
➡ what feature
rate limits gotchas
https://api.twitter.com/1/account/settings.json
'x-ratelimit-class': 'api_identified',
'x-ratelimit-limit': '350',
'x-ratelimit-remaining': '257'
https://api.twitter.com/1/users/search.json?q=europython
'x-featureratelimit-class': 'usersearch',
'x-featureratelimit-limit': '180',
'x-featureratelimit-remaining': '179'
social network
facebook.com/facciamoadesso
@facciamoadesso
the results
on facebook
lessons learned
Grazie. Thank you.
Questions ?
Andrew Mleczko
Python Dev
Plone Framework Team member
amleczko@redturtle.it
tw: @amleczko
Credits
http://www.flickr.com/photos/mgstyer/5083898608
http://www.flickr.com/photos/55483178@N02/5260890765
See also:
http://blog.redturtle.it/redturtle/earthquake-plone-to-the-rescue

Celery and the social networks