SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
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

Contenu connexe

Similaire à 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 BrowsersGoogleTecTalks
 
Performance Improvements in Browsers
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsersjeresig
 
Microblogging via XMPP
Microblogging via XMPPMicroblogging via XMPP
Microblogging via XMPPStoyan Zhekov
 
Symfony 2.0
Symfony 2.0Symfony 2.0
Symfony 2.0GrUSP
 
Generator Tricks for Systems Programmers
Generator Tricks for Systems ProgrammersGenerator Tricks for Systems Programmers
Generator Tricks for Systems ProgrammersHiroshi 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 JavaScriptjeresig
 
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 GoCloudflare
 
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.comVoxeo Corp
 
2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdfUtabeUtabe
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks 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 goDvir 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 2015Igor 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 GoAmr Hassan
 
Going Live! with Comet
Going Live! with CometGoing Live! with Comet
Going Live! with CometSimon Willison
 

Similaire à 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
 

Plus de 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 oneSylvain Zimmer
 
Ranking the Web with Spark
Ranking the Web with SparkRanking the Web with Spark
Ranking the Web with SparkSylvain 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 2013Sylvain 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 JavascriptSylvain Zimmer
 
Joshfire Framework 0.9 Technical Overview
Joshfire Framework 0.9 Technical OverviewJoshfire Framework 0.9 Technical Overview
Joshfire Framework 0.9 Technical OverviewSylvain 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 NodeJSSylvain 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 4Sylvain Zimmer
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 
Archicamp présentation
Archicamp présentationArchicamp présentation
Archicamp présentationSylvain Zimmer
 

Plus de 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
 

Dernier

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

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