This document discusses asynchronous programming using Python. It begins with introductions and discusses some of the buzzwords around asynchronous programming like Node.js, Tornado, and event loops. It then provides a brief history of threading, multiprocessing, and asynchronous programming. It defines what an event loop is and discusses concepts like callbacks and deferreds. It notes that asynchronous code is generally harder to write and can be slower than synchronous code. However, asynchronous programming allows for greater scalability by avoiding threads and shared state.
Computer Science is an interesting subject which helps students to develop their problem solving and computational thinking skills. The problem solving and algorithmic nature of computer science also promotes students’ creativity and innovation. However, teaching of computer science is different from other science subjects and requires special pedagogical skills. This presentation covers these aspects.
Computer Science is an interesting subject which helps students to develop their problem solving and computational thinking skills. The problem solving and algorithmic nature of computer science also promotes students’ creativity and innovation. However, teaching of computer science is different from other science subjects and requires special pedagogical skills. This presentation covers these aspects.
Apresentação realizada no FLISol Campina Grande 2015 sobre a linguagem Go.
Os códigos utilizados podem ser encontrados aqui https://github.com/allisson/golang-exemplos
Python for class 11 (CBSE Computer science sub code 083)Nitin Kumar
Right now I am in mid of completing this book. Just uploaded first and part of second chapter. Will upload whole once I am done.
Can contact me at nitin_k@outlook.com for more details or to get a copy of this book.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Apresentação realizada no FLISol Campina Grande 2015 sobre a linguagem Go.
Os códigos utilizados podem ser encontrados aqui https://github.com/allisson/golang-exemplos
Python for class 11 (CBSE Computer science sub code 083)Nitin Kumar
Right now I am in mid of completing this book. Just uploaded first and part of second chapter. Will upload whole once I am done.
Can contact me at nitin_k@outlook.com for more details or to get a copy of this book.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Welcome to the first live UiPath Community Day Dubai! Join us for this unique occasion to meet our local and global UiPath Community and leaders. You will get a full view of the MEA region's automation landscape and the AI Powered automation technology capabilities of UiPath. Also, hosted by our local partners Marc Ellis, you will enjoy a half-day packed with industry insights and automation peers networking.
📕 Curious on our agenda? Wait no more!
10:00 Welcome note - UiPath Community in Dubai
Lovely Sinha, UiPath Community Chapter Leader, UiPath MVPx3, Hyper-automation Consultant, First Abu Dhabi Bank
10:20 A UiPath cross-region MEA overview
Ashraf El Zarka, VP and Managing Director MEA, UiPath
10:35: Customer Success Journey
Deepthi Deepak, Head of Intelligent Automation CoE, First Abu Dhabi Bank
11:15 The UiPath approach to GenAI with our three principles: improve accuracy, supercharge productivity, and automate more
Boris Krumrey, Global VP, Automation Innovation, UiPath
12:15 To discover how Marc Ellis leverages tech-driven solutions in recruitment and managed services.
Brendan Lingam, Director of Sales and Business Development, Marc Ellis
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Enhancing Performance with Globus and the Science DMZGlobus
ESnet has led the way in helping national facilities—and many other institutions in the research community—configure Science DMZs and troubleshoot network issues to maximize data transfer performance. In this talk we will present a summary of approaches and tips for getting the most out of your network infrastructure using Globus Connect Server.
The Metaverse and AI: how can decision-makers harness the Metaverse for their...Jen Stirrup
The Metaverse is popularized in science fiction, and now it is becoming closer to being a part of our daily lives through the use of social media and shopping companies. How can businesses survive in a world where Artificial Intelligence is becoming the present as well as the future of technology, and how does the Metaverse fit into business strategy when futurist ideas are developing into reality at accelerated rates? How do we do this when our data isn't up to scratch? How can we move towards success with our data so we are set up for the Metaverse when it arrives?
How can you help your company evolve, adapt, and succeed using Artificial Intelligence and the Metaverse to stay ahead of the competition? What are the potential issues, complications, and benefits that these technologies could bring to us and our organizations? In this session, Jen Stirrup will explain how to start thinking about these technologies as an organisation.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
7. Introductions
• Hi, I'm Aurynn
• This is a hedgehog
Wednesday, 31 August, 11
8. I’m more like a Magpie
• Shiny things are SO COOL
• I could talk about how
shiny they are until
http://www.flickr.com/photos/cmg2011/5147250751/
Wednesday, 31 August, 11
10. Buzzword Bingo
• Much ado about Node.js
• Event Driven!
• Tornado, from Facebook!
• Event loops!
• “Web Scale!”
Wednesday, 31 August, 11
11. Lots of Chatter
• Without lots of research, it’s
just kind of noise
http://en.wikipedia.org/wiki/File:Carl_Friedrich_Gauss.jpg
Wednesday, 31 August, 11
16. And it’s the sort of that is
important
Wednesday, 31 August, 11
17. A TERRIBLY BRIEF,
PROBABLY INACCURATE
HISTORY
Wednesday, 31 August, 11
18. Threading, you’ve heard of it
• Really common
• Java, .NET, even some
Python
• Super awesome! Shared
memory, shared scopes, fun
all around..
Wednesday, 31 August, 11
19. Surprisingly good, until it isn’t
• Very difficult to access
shared state safely
• Race conditions
• Even experts have a hard
time of it
• Generally hard to do right
Wednesday, 31 August, 11
20. The kernel cares about when things happen, not you.
Multiprocessing No problems with locks or race conditions, since you
don’t have a consistent memory region
Fork() makes life so easy!
the MP model even makes multiple-systems a viable
approach: it’s pretty trivial to SSH into another
computer and run a program, or a batch of programs.
• Let the kernel care!
• Fairly easy to write MP
code on unix-likes
• Can even go multi-system
http://www.flickr.com/photos/epw/2876377014/
Wednesday, 31 August, 11
21. Hard to share Data
• It’s not easy to send data
between processes
• Parsing stdout, or trying to
get a shmem
implementation working.
• import multiprocessing can
be.. quirky.
Wednesday, 31 August, 11
22. Asynchronous!
• Like threading, everything
is in a single process
• All my Variables, All the
Time
• No race conditions (mostly)
• Guarantee of no
concurrent execution
http://www.flickr.com/photos/rachelpasch/3754315974/
Wednesday, 31 August, 11
23. Not all Unicorns and Rainbows
Just like MP and threads, event loops have their own caveats and major
constraints.
Your code can’t run indefinitely, and the longer it runs, the longer your process
stalls.
Like threading, it’s still Not Easy to get your head around how to write
asynchronous code, and this is something else we’ll go into in a bit more detail.
Single mistakes, not catching your errors in The Approved Way? You can very
easily trash your entire program and cause yourself to hang. Why does this
happen? It comes back to the first point of You Need to Let Go.
• You have to Let Go
• Bending your mind to the
Asynchronous Way is still
hard
• A single mistake can hang
• Probably going to be slower.
http://www.flickr.com/photos/digitalpapercuts/5737975961
Wednesday, 31 August, 11
24. SO REALLY, WHAT IS ASYNC?
So, I’ve made some broad generalizations about event
loops, and the caveats they bring to the table.
Let’s go into some more detail about what they do and
are, and how those caveats actually work, and look at
some code to really show how to work in the
Asynchronous Way.
Wednesday, 31 August, 11
25. so, to get this far, we haven’t really
answered the first question:
what *is* an event loop?
What is an event loop?
Wednesday, 31 August, 11
26. What is an event loop? At its heart, an event loop is just a long-running
while loop, iterating over a set of callbacks, or
events to be run in the future.
When an event gets triggered, often in the form
of a socket message, or the completion of
another function, or a timeout firing.
• A long-running while loop
• When an event triggers, the loop catches this fact
• Events are pretty generic
Wednesday, 31 August, 11
28. Then what? When you added the event you care about, you
also added a callback. A callback is simply a
Python function that gets run with the results
of the event.
The return value of a function, or the data
coming off your socket, or whatever is what
this function gets passed.
The great part is that this function definition is
allowed to be *any callable* object in Python. A
class with .__call__, a function, a bound method
on an object, whatever scope you like, it has.
• Let my code know!
• This code can be any callable
Wednesday, 31 August, 11
29. But once it’s in your code..
Wednesday, 31 August, 11
30. You have to Let Go As you’ve probably figured out, what happens in
an event system is analogous to co-operative
multitasking.
When an event fires and your callback gets run,
what happens?
Since it’s a standard method call,
Event Loop
Your Code
Wednesday, 31 August, 11
31. You have to Let Go control is handed over to your method, and
doesn’t return to the event loop UNTIL YOU
RETURN.
Event Loop
Your Code
Wednesday, 31 August, 11
32. We could be here a while... control is handed over to your method, and
doesn’t return to the event loop UNTIL YOU
RETURN.
So let’s say your particular callback takes, oh
second to do its thing, as it’s a particularly
computationally intensive, your entire event
loop is unable to do anything else.
Let’s compute Pi to
a BILLION decimal
places!
Your Code
Wednesday, 31 August, 11
33. Not just silly maths, either This happens no matter what your code does,
it silly math or a web site reaching out to
MySQL for data, or going to disk to open a file
iterating over a long array, or even waiting on
the user to do something.
As long as your code hasn’t returned, your ent
program has STALLED.
I need some data
from MySQL.
Your Code
Wednesday, 31 August, 11
34. You have STALLED.
http://www.flickr.com/photos/neilwill/5023734329/
Wednesday, 31 August, 11
35. It should be fairly obvious that this is bad, and why it’s bad.
To use the example of a hypothetical website, if you’re stalled
waiting for the database, you can’t accept new connections,
and you can’t even give an indication why. Your site will
*appear* to perform slowly.
Is that really bad?
Wednesday, 31 August, 11
36. Solving this isn’t easy, and requires adjusting your mental
model on how programs flow.
In Twisted, programs have to be written with the idea that a
method call won’t return the results you expect, but instead
an object that will tell a function what your data is.
Asynchronous code is harder
Wednesday, 31 August, 11
37. Asynchronous code is harder
For instance, x = y() won’t do what you expect.
How can it, when you’re not actually
• x = y() doesn’t work anymore.
Wednesday, 31 August, 11
38. Asynchronous code is harder
In this model, you end up with very tiny
functions that perform very small, discrete
amounts of work, before releasing control back
to the event loop.
In order for these very tiny functions to be
useful, we have to keep tight control over our
scope, and an easy way to do that is by using
closures.
• x = y() doesn’t work anymore.
• Requires very tiny functions
Wednesday, 31 August, 11
39. This is what Twisted does As you can see here, we’ve expanded our row
processor into its own function, as well as adding
an error handler to the t wisted Deferred.
Wednesday, 31 August, 11
40. The first way in which asynchronous code can be written is
through the use of closures.
A closure is a funky sort of internal, anonymous function
that “closes over” the scope of the function it’s defined in.
This can be very powerful, as the closure effectively
“resumes” back in the middle of the original function, can
update state, and generally do useful things.
Wait, wait, what just happened?
Wednesday, 31 August, 11
41. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
Deferred, the Core of Twisted
Wednesday, 31 August, 11
42. The Core of Twisted
• Most APIs built on Twisted return Deferreds
• Almost always involve user code
Wednesday, 31 August, 11
43. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
But what is a Deferred?
Wednesday, 31 August, 11
44. But what is it? These are the basic features that you probably care
about in a deferred;
Add callbacks and errbacks, which we’ve already
covered a bit of,
and these new methods, .callback and .errback.
Wednesday, 31 August, 11
45. For instance, x = y() won’t do what you expect.
Segue Power! How can it, when you’re not actually
• .callback starts the callback chain
• .errback causes the callback chain to explode and die
messily
Wednesday, 31 August, 11
46. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
errback is structurally identical to
callbacks
Wednesday, 31 August, 11
48. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
What’s the key here?
Wednesday, 31 August, 11
49. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
It doesn’t happen right away.
Wednesday, 31 August, 11
52. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
Composition
Wednesday, 31 August, 11
53. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
Or, chaining callbacks
Wednesday, 31 August, 11
55. What that was was a *deferred*, basically the core
response that you’ll get out of an API in Twisted.
What a deferred is, is an indicator that something is going to
happen *later on*, as opposed to right now.
This comes back to the core ideal of having to let go, and let’s
go back to the code to explain further
Synchronous callback chain
Wednesday, 31 August, 11
56. ASYNCHRONOUS != FASTER
The final caveat on our List of Asynchronous Problems
is the idea I’ve run into that asynchronous code is, by
the very fact of running on an evented IO ser ver, it
will be faster.
This idea is all sorts of wrong.
Synchronous code that simply runs inside of a event-
driven IO system like Twisted or Tornado is naturally
going to be slower than the same code running
standalone.
Wednesday, 31 August, 11
57. Synchronous code that simply runs inside of a event-driven
IO system like Twisted or Tornado is naturally going to be
slower than the same code running standalone.
The event loop is overhead
Wednesday, 31 August, 11
58. And, as you’ve already seen on how to structure
asynchronous programs, effectively useless, unless you take
the time to program to take advantage of an asynchronous
event loop.
The event loop is overhead...
..and without proper coding, useless
Wednesday, 31 August, 11
60. WHY BOTHER?
Why spend extra time doing it the Hard Way, the way
where you are required to do more work and write code
in completely new ways?
Wednesday, 31 August, 11
61. The real advantage, the real power of asynchronous
programming is the level of scale to which you can go.
No threads means no thread overhead, and no complexity of
maintaining locks and trying to share state.
Nginx, well-regarded as one of the fastest webser vers
around, is entirely built around asynchronous programming.
Scales beautifully
Wednesday, 31 August, 11
62. Once you really “get it”, the entire idea starts seeming
terribly elegant and worthwhile, and you start looking for
how to process code asynchronously in all aspects of your
programming.
Terribly elegant
Wednesday, 31 August, 11
63. You also end up in a position where you’re writing far more
reusable code.
Why? Well, you need to have these functions which run as
callbacks, and as we’ll go into in a little bit, those same
callbacks can be chained together. There’s very little point in
rewriting code all the time to
More re-usable code
Wednesday, 31 August, 11
64. What do I mean by this? Your code is often going to be
waiting for other servers - webser vers, database ser vers,
net work, file, Everything.
So the example I have the
Closer mapping to reality
Wednesday, 31 August, 11
65. LITTLE BITS OF TORNADOS
Since I’ve spent most of my time so far talking
about Twisted as opposed to the other “major”
asynchronous platform, I’d like to devote a little bit
of time to Tornado.
Wednesday, 31 August, 11
66. Tornado, while it does have an internal IO loop, and libraries
*do* use it standalone, the vast majority of examples you’ll
run across take the idea of it being a web framework akin to
Pylons or Pyramid or Bottle.
Event loop + web framework
Wednesday, 31 August, 11
70. Tornado, while it does have an internal IO loop, and libraries
*do* use it standalone, the vast majority of examples you’ll
run across take the idea of it being a web framework akin to
Pylons or Pyramid or Bottle.
.add_callback(my_function)
Wednesday, 31 August, 11