SlideShare a Scribd company logo
Twisted
                       Présentation & Usecases




Monday, June 1, 2009
Twisted?

                       • Framework pour applis réseau
                       • 100% Python, quelques optimisations en C
                       • Projet opensource stable, bien maintenu
                       • Programmation asynchrone

Monday, June 1, 2009
Asynchrone?

                       • Synonymes : “event-driven”, “non-blocking”
                       • Toutes les fonctions doivent retourner
                         “rapidement”
                       • 1 seul thread
                       • Reactor pattern

Monday, June 1, 2009
Sync vs. Async
         def google_sync(search)
             html = urllib.urlopen(“http://google.com/?q=”+search”).read()
             return [r[1] for r in re.split(“<h3>(.*?)</h3>”,html)]

         print google_sync(“pycon fr”)
         print google_sync(“pycon us”)




         def google_async(search)
             async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”)
             async_call.addCallback(gotresults)

         def gotresults(html)
             print [r[1] for r in re.split(“<h3>(.*?)</h3>”,html)]

         google_async(“pycon fr”)
         google_async(“pycon us”)

         twisted.internet.reactor.run()



Monday, June 1, 2009
“C’est plus compliqué!”
                       • Oui mais
                       • 100 requêtes en parallèle ?




Monday, June 1, 2009
“C’est plus compliqué!”
                       • Oui mais
                       • 100 requêtes en parallèle ?
         results = []

         class google_thread(Thread):
             def __init__(self,search):
                 self.search = search

                def run():
                    html = urllib.urlopen(“http://google.com/?q=”+search”).read()
                    results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)])

         threads = [google_thread(“pycon fr”), google_thread(“pycon us”)]
         [thread.start() for thread in threads]
         print results



Monday, June 1, 2009
Et là ?
         results = []

         class google_thread(Thread):
             def __init__(self,search):
                 self.search = search

                def run():
                    html = urllib.urlopen(“http://google.com/?q=”+search”).read()
                    results.append(“Resultats pour ‘%s’ :” % self.search)
                    results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)])

         threads = [google_thread(“pycon fr”), google_thread(“pycon us”)]
         [thread.start() for thread in threads]




Monday, June 1, 2009
Thread safety
         results = []

         class google_thread(Thread):
             def __init__(self,search):
                 self.search = search

                def run():
                    html = urllib.urlopen(“http://google.com/?q=”+search”).read()
                    acquire_lock(results)
                    results.append(“Resultats pour ‘%s’ :” % self.search)
                    results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)])
                    release_lock(results)

         threads = [google_thread(“pycon fr”), google_thread(“pycon us”)]
         [thread.start() for thread in threads]




Monday, June 1, 2009
Thread safety

                       • Locks
                       • Queues
                       • Semaphores
                       • ...

Monday, June 1, 2009
Thread safety




Monday, June 1, 2009
Version asynchrone

         def google_async(search)
             async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”)
             async_call.addCallback(gotresults)

         def gotresults(html)
             print [r[1] for r in re.split(“<h3>(.*?)</h3>”)]

         google_async(“pycon fr”)
         google_async(“pycon us”)

         twisted.internet.reactor.run()




Monday, June 1, 2009
Version asynchrone
                       • 1 seul thread!
         results = []

         def google_async(search)
             async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”)
             async_call.addCallback(gotresults,search)

         def gotresults(html,search)
             results.append(“Resultats pour ‘%s’ :” % search)
             results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)])

         google_async(“pycon fr”)
         google_async(“pycon us”)

         twisted.internet.reactor.run()




Monday, June 1, 2009
Deferreds
          def google_async(search)
              async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”)
              async_call.addCallback(gotresults)




                       • Promesse d’un resultat futur
                       • addCallback
                       • addErrback
                       • Chains
                       • DeferredLists
Monday, June 1, 2009
Deferreds




Monday, June 1, 2009
Reactor

                       • “Dont call us, we’ll call you”
                       • Event Loop
                       • S’occupe d’appeller tous les callbacks
                       • “Remplace” le GIL, thread switching
                       • “Pluggable” : select/poll, epoll, GUI, ...

Monday, June 1, 2009
Autres avantages
                       • Librairie très complète : HTTP, SSH, IRC,
                         DNS, IMAP, Jabber, SMTP, Telnet, ...
                       • Ne pas réinventer la roue / patterns
                       • Déploiement rapide d’applis complexes
                       • Threadpool
                       • Encapsulation/design
                       • Moins de surprises
Monday, June 1, 2009
Utilisateurs de Twisted
                       • Apple
                       • NASA
                       • Justin.tv
                       • Bittorrent / Zope / Freevo / Buildbot / ...
                       • ???
                       • Jamendo :)
Monday, June 1, 2009
Twisted chez Jamendo

                       • Upload servers
                       • Log servers
                       • Radio servers
                       • Widget servers
                       • Streaming / Download servers

Monday, June 1, 2009
Download servers
                       • 10k lignes de code
                       • HTTP “sécurisé”, download queues
                       • FTP avec virtual filesystem
                       • Génération de zips à la volée
                       • Seeds BitTorrent
                       • Logs UDP / Monitoring
                       • twisted.manhole
Monday, June 1, 2009
Merci de votre attention!

                                 Sylvain Zimmer
                         sylvain@jamendo.com
                            twitter.com/sylvinus




Monday, June 1, 2009

More Related Content

Similar to Twisted presentation & Jamendo usecases

[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
Johnny Sung
 
Performance Improvements in Browsers
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsers
jeresig
 
Performance Improvements In Browsers
Performance Improvements In BrowsersPerformance Improvements In Browsers
Performance Improvements In Browsers
GoogleTecTalks
 
Microblogging via XMPP
Microblogging via XMPPMicroblogging via XMPP
Microblogging via XMPP
Stoyan Zhekov
 
Symfony 2.0
Symfony 2.0Symfony 2.0
Symfony 2.0
GrUSP
 
Generator Tricks for Systems Programmers
Generator Tricks for Systems ProgrammersGenerator Tricks for Systems Programmers
Generator Tricks for Systems Programmers
Hiroshi Ono
 
Performance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScriptPerformance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScript
jeresig
 
JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)
JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)
JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)
PROIDEA
 
An Introduction to Go
An Introduction to GoAn Introduction to Go
An Introduction to Go
Cloudflare
 
Performance tests with Gatling (extended)
Performance tests with Gatling (extended)Performance tests with Gatling (extended)
Performance tests with Gatling (extended)
Andrzej Ludwikowski
 
Voicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.comVoicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.com
Voxeo Corp
 
2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf
UtabeUtabe
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
Geeks Anonymes
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
Dvir Volk
 
How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
Wilfried Schobeiri
 
JavaScript in 2015
JavaScript in 2015JavaScript in 2015
JavaScript in 2015
Igor Laborie
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
Ippei Ogiwara
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
Amr Hassan
 
Whats New In Groovy 1.6?
Whats New In Groovy 1.6?Whats New In Groovy 1.6?
Whats New In Groovy 1.6?
Guillaume Laforge
 
Going Live! with Comet
Going Live! with CometGoing Live! with Comet
Going Live! with Comet
Simon Willison
 

Similar to Twisted presentation & Jamendo usecases (20)

[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
 
Performance Improvements in Browsers
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsers
 
Performance Improvements In Browsers
Performance Improvements In BrowsersPerformance Improvements In Browsers
Performance Improvements In Browsers
 
Microblogging via XMPP
Microblogging via XMPPMicroblogging via XMPP
Microblogging via XMPP
 
Symfony 2.0
Symfony 2.0Symfony 2.0
Symfony 2.0
 
Generator Tricks for Systems Programmers
Generator Tricks for Systems ProgrammersGenerator Tricks for Systems Programmers
Generator Tricks for Systems Programmers
 
Performance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScriptPerformance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScript
 
JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)
JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)
JDD 2017: Performance tests with Gatling (Andrzej Ludwikowski)
 
An Introduction to Go
An Introduction to GoAn Introduction to Go
An Introduction to Go
 
Performance tests with Gatling (extended)
Performance tests with Gatling (extended)Performance tests with Gatling (extended)
Performance tests with Gatling (extended)
 
Voicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.comVoicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.com
 
2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
 
JavaScript in 2015
JavaScript in 2015JavaScript in 2015
JavaScript in 2015
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
 
Whats New In Groovy 1.6?
Whats New In Groovy 1.6?Whats New In Groovy 1.6?
Whats New In Groovy 1.6?
 
Going Live! with Comet
Going Live! with CometGoing Live! with Comet
Going Live! with Comet
 

More from Sylvain Zimmer

Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
Sylvain Zimmer
 
Ranking the Web with Spark
Ranking the Web with SparkRanking the Web with Spark
Ranking the Web with Spark
Sylvain Zimmer
 
[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013
[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013
[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013
Sylvain Zimmer
 
140byt.es - The Dark Side of Javascript
140byt.es - The Dark Side of Javascript140byt.es - The Dark Side of Javascript
140byt.es - The Dark Side of Javascript
Sylvain Zimmer
 
Joshfire Framework 0.9 Technical Overview
Joshfire Framework 0.9 Technical OverviewJoshfire Framework 0.9 Technical Overview
Joshfire Framework 0.9 Technical Overview
Sylvain Zimmer
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
Sylvain Zimmer
 
no.de quick presentation at #ParisJS 4
no.de quick presentation at #ParisJS 4no.de quick presentation at #ParisJS 4
no.de quick presentation at #ParisJS 4
Sylvain Zimmer
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
Sylvain Zimmer
 
Archicamp présentation
Archicamp présentationArchicamp présentation
Archicamp présentationSylvain Zimmer
 

More from Sylvain Zimmer (9)

Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
 
Ranking the Web with Spark
Ranking the Web with SparkRanking the Web with Spark
Ranking the Web with Spark
 
[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013
[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013
[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013
 
140byt.es - The Dark Side of Javascript
140byt.es - The Dark Side of Javascript140byt.es - The Dark Side of Javascript
140byt.es - The Dark Side of Javascript
 
Joshfire Framework 0.9 Technical Overview
Joshfire Framework 0.9 Technical OverviewJoshfire Framework 0.9 Technical Overview
Joshfire Framework 0.9 Technical Overview
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
 
no.de quick presentation at #ParisJS 4
no.de quick presentation at #ParisJS 4no.de quick presentation at #ParisJS 4
no.de quick presentation at #ParisJS 4
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Archicamp présentation
Archicamp présentationArchicamp présentation
Archicamp présentation
 

Recently uploaded

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 

Recently uploaded (20)

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 

Twisted presentation & Jamendo usecases

  • 1. Twisted Présentation & Usecases Monday, June 1, 2009
  • 2. Twisted? • Framework pour applis réseau • 100% Python, quelques optimisations en C • Projet opensource stable, bien maintenu • Programmation asynchrone Monday, June 1, 2009
  • 3. Asynchrone? • Synonymes : “event-driven”, “non-blocking” • Toutes les fonctions doivent retourner “rapidement” • 1 seul thread • Reactor pattern Monday, June 1, 2009
  • 4. Sync vs. Async def google_sync(search) html = urllib.urlopen(“http://google.com/?q=”+search”).read() return [r[1] for r in re.split(“<h3>(.*?)</h3>”,html)] print google_sync(“pycon fr”) print google_sync(“pycon us”) def google_async(search) async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”) async_call.addCallback(gotresults) def gotresults(html) print [r[1] for r in re.split(“<h3>(.*?)</h3>”,html)] google_async(“pycon fr”) google_async(“pycon us”) twisted.internet.reactor.run() Monday, June 1, 2009
  • 5. “C’est plus compliqué!” • Oui mais • 100 requêtes en parallèle ? Monday, June 1, 2009
  • 6. “C’est plus compliqué!” • Oui mais • 100 requêtes en parallèle ? results = [] class google_thread(Thread): def __init__(self,search): self.search = search def run(): html = urllib.urlopen(“http://google.com/?q=”+search”).read() results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)]) threads = [google_thread(“pycon fr”), google_thread(“pycon us”)] [thread.start() for thread in threads] print results Monday, June 1, 2009
  • 7. Et là ? results = [] class google_thread(Thread): def __init__(self,search): self.search = search def run(): html = urllib.urlopen(“http://google.com/?q=”+search”).read() results.append(“Resultats pour ‘%s’ :” % self.search) results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)]) threads = [google_thread(“pycon fr”), google_thread(“pycon us”)] [thread.start() for thread in threads] Monday, June 1, 2009
  • 8. Thread safety results = [] class google_thread(Thread): def __init__(self,search): self.search = search def run(): html = urllib.urlopen(“http://google.com/?q=”+search”).read() acquire_lock(results) results.append(“Resultats pour ‘%s’ :” % self.search) results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)]) release_lock(results) threads = [google_thread(“pycon fr”), google_thread(“pycon us”)] [thread.start() for thread in threads] Monday, June 1, 2009
  • 9. Thread safety • Locks • Queues • Semaphores • ... Monday, June 1, 2009
  • 11. Version asynchrone def google_async(search) async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”) async_call.addCallback(gotresults) def gotresults(html) print [r[1] for r in re.split(“<h3>(.*?)</h3>”)] google_async(“pycon fr”) google_async(“pycon us”) twisted.internet.reactor.run() Monday, June 1, 2009
  • 12. Version asynchrone • 1 seul thread! results = [] def google_async(search) async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”) async_call.addCallback(gotresults,search) def gotresults(html,search) results.append(“Resultats pour ‘%s’ :” % search) results.append([r[1] for r in re.split(“<h3>(.*?)</h3>”,html)]) google_async(“pycon fr”) google_async(“pycon us”) twisted.internet.reactor.run() Monday, June 1, 2009
  • 13. Deferreds def google_async(search) async_call = twisted.web.client.getPage(“http://google.com/?q=”+search”) async_call.addCallback(gotresults) • Promesse d’un resultat futur • addCallback • addErrback • Chains • DeferredLists Monday, June 1, 2009
  • 15. Reactor • “Dont call us, we’ll call you” • Event Loop • S’occupe d’appeller tous les callbacks • “Remplace” le GIL, thread switching • “Pluggable” : select/poll, epoll, GUI, ... Monday, June 1, 2009
  • 16. Autres avantages • Librairie très complète : HTTP, SSH, IRC, DNS, IMAP, Jabber, SMTP, Telnet, ... • Ne pas réinventer la roue / patterns • Déploiement rapide d’applis complexes • Threadpool • Encapsulation/design • Moins de surprises Monday, June 1, 2009
  • 17. Utilisateurs de Twisted • Apple • NASA • Justin.tv • Bittorrent / Zope / Freevo / Buildbot / ... • ??? • Jamendo :) Monday, June 1, 2009
  • 18. Twisted chez Jamendo • Upload servers • Log servers • Radio servers • Widget servers • Streaming / Download servers Monday, June 1, 2009
  • 19. Download servers • 10k lignes de code • HTTP “sécurisé”, download queues • FTP avec virtual filesystem • Génération de zips à la volée • Seeds BitTorrent • Logs UDP / Monitoring • twisted.manhole Monday, June 1, 2009
  • 20. Merci de votre attention! Sylvain Zimmer sylvain@jamendo.com twitter.com/sylvinus Monday, June 1, 2009