SlideShare una empresa de Scribd logo
1 de 22
Advanced Track: Asynchronous  Threads Bil Corry lasso.pro
What Are Async Threads? Code that executes in parallel to the currently processing page.
Why Use Async Threads? ,[object Object]
Typical Lasso Request Model ,[object Object]
Web server determines the request is for Lasso and passes it to the Lasso connector
Lasso connector communicates with Lasso Server and sends the request
Lasso Server parses request, replies to Lasso connector
Lasso connector replies to web server
Web server replies to browser
Lasso Async Thread Model ,[object Object]
Just like a normal page, the thread will run until: ,[object Object]
It crashes
It is terminated for taking too long
Lasso site or server is shut down ,[object Object]
Lasso Async Thread Model (cont) ,[object Object]
It will also not have access to the variables of the page that created it.
All file paths must be absolute from the hard disk root – [include] does not work
Lasso Async Thread Model (cont) ,[object Object]
An async thread will execute according to its priority and the load on Lasso
Basic Example Async threads are surrounded by curly-braces and initiated using ->asasyn c: [{'Hello World'}->asasync] The above code doesn't show anything in the browser, but it does run asynchronously.
Sending Data to Async Thread ->asasync allows you to add params to pass into the async thread [{ var('p1') = params->find('p1')->get(1)->value } ->asasync(-params=array('p1'=1, 'p2'=2))] Can also use globals (or other shared resources), but take care to correctly send the right message to the right thread and use [thread_atomic] to keep access to the global thread-safe
Template For Copying Vars To Async Thread <?LassoScript  // from: http://www.lassotech.com/async // stuff on your page not async here... // --------------  BEGIN OF ASYNC CODE -------------- { // --------------  BEGIN OF ASYNC CODE -------------- // -------------------- //  process async! // -------------------- // // NOTE: Code below this point is processed in it's own thread! // Lasso_ExecutionTimeLimit(60 * 60); // in seconds, set this to something reasonable Thread_SetPriority(Thread_GetCurrentID, Thread_Priority_Low); // set priority // recreate vars - this makes all the vars on the page available to the async thread iterate: params->(find:'-vars')->(get:1)->value, local:'var'; (var: #var->name) = #var->value; /iterate; // do stuff here that you want in it's own thread... // --------------  END OF ASYNC CODE -------------- }->(asasync: -params=(array: '-vars' = vars)); // --------------  END OF ASYNC CODE --------------  // do more stuff on the current page... ?>

Más contenido relacionado

La actualidad más candente

Replacing Squid with ATS
Replacing Squid with ATSReplacing Squid with ATS
Replacing Squid with ATSKit Chan
 
Terraform 0.9 + good practices
Terraform 0.9 + good practicesTerraform 0.9 + good practices
Terraform 0.9 + good practicesRadek Simko
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultBram Vogelaar
 
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)Stephane Jourdan
 
DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)Soshi Nemoto
 
Scaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web ServicesScaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web ServicesAndrew Turner
 
Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2Nate Murray
 
Creating Reusable Puppet Profiles
Creating Reusable Puppet ProfilesCreating Reusable Puppet Profiles
Creating Reusable Puppet ProfilesBram Vogelaar
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done rightDan Vaida
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Brian Schott
 
Infrastructure as Code with Terraform
Infrastructure as Code with TerraformInfrastructure as Code with Terraform
Infrastructure as Code with TerraformMario IC
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
 

La actualidad más candente (20)

Replacing Squid with ATS
Replacing Squid with ATSReplacing Squid with ATS
Replacing Squid with ATS
 
Terraform 0.9 + good practices
Terraform 0.9 + good practicesTerraform 0.9 + good practices
Terraform 0.9 + good practices
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp Vault
 
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
 
DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)
 
Scaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web ServicesScaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web Services
 
Perl dancer
Perl dancerPerl dancer
Perl dancer
 
Tuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for LogsTuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for Logs
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2
 
Ubic
UbicUbic
Ubic
 
Top Node.js Metrics to Watch
Top Node.js Metrics to WatchTop Node.js Metrics to Watch
Top Node.js Metrics to Watch
 
Creating Reusable Puppet Profiles
Creating Reusable Puppet ProfilesCreating Reusable Puppet Profiles
Creating Reusable Puppet Profiles
 
Triple Blitz Strike
Triple Blitz StrikeTriple Blitz Strike
Triple Blitz Strike
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
Infrastructure as Code with Terraform
Infrastructure as Code with TerraformInfrastructure as Code with Terraform
Infrastructure as Code with Terraform
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 

Destacado

интернет развитие
интернет развитиеинтернет развитие
интернет развитиеKanio
 
Sociala Medier Och Affärsnytta - Albert Bengtson
Sociala Medier Och Affärsnytta -  Albert BengtsonSociala Medier Och Affärsnytta -  Albert Bengtson
Sociala Medier Och Affärsnytta - Albert BengtsonAlbert Bengtson
 
Brand Management Recession
Brand Management RecessionBrand Management Recession
Brand Management Recessioncolortray
 
SplunkLive! London - Splunk App for Stream & MINT Breakout
SplunkLive! London - Splunk App for Stream & MINT BreakoutSplunkLive! London - Splunk App for Stream & MINT Breakout
SplunkLive! London - Splunk App for Stream & MINT BreakoutSplunk
 

Destacado (7)

интернет развитие
интернет развитиеинтернет развитие
интернет развитие
 
Sociala Medier Och Affärsnytta - Albert Bengtson
Sociala Medier Och Affärsnytta -  Albert BengtsonSociala Medier Och Affärsnytta -  Albert Bengtson
Sociala Medier Och Affärsnytta - Albert Bengtson
 
2008 11 Berlin
2008 11 Berlin2008 11 Berlin
2008 11 Berlin
 
Brand Management Recession
Brand Management RecessionBrand Management Recession
Brand Management Recession
 
SplunkLive! London - Splunk App for Stream & MINT Breakout
SplunkLive! London - Splunk App for Stream & MINT BreakoutSplunkLive! London - Splunk App for Stream & MINT Breakout
SplunkLive! London - Splunk App for Stream & MINT Breakout
 
360 Fremtiden Er Her Idag
360   Fremtiden Er Her Idag360   Fremtiden Er Her Idag
360 Fremtiden Er Her Idag
 
2009 02 Madagascar Images
2009 02 Madagascar Images2009 02 Madagascar Images
2009 02 Madagascar Images
 

Similar a Asynchronous Threads in Lasso 8.5

Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabricandymccurdy
 
Real-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioReal-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioRick Copeland
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabricandymccurdy
 
Analysis bottleneck in J2EE application
Analysis bottleneck in J2EE applicationAnalysis bottleneck in J2EE application
Analysis bottleneck in J2EE applicationTerry Cho
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Applicationguest1f2740
 
How we setup Rsync-powered Incremental Backups
How we setup Rsync-powered Incremental BackupsHow we setup Rsync-powered Incremental Backups
How we setup Rsync-powered Incremental Backupsnicholaspaun
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardSV Ruby on Rails Meetup
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppetelliando dias
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)Wesley Beary
 
Hadoop spark performance comparison
Hadoop spark performance comparisonHadoop spark performance comparison
Hadoop spark performance comparisonarunkumar sadhasivam
 
Apache Traffic Server
Apache Traffic ServerApache Traffic Server
Apache Traffic Serversupertom
 
Pegasus - automate, recover, and debug scientific computations
Pegasus - automate, recover, and debug scientific computationsPegasus - automate, recover, and debug scientific computations
Pegasus - automate, recover, and debug scientific computationsRafael Ferreira da Silva
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate WorksGoro Fuji
 
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...HostedbyConfluent
 
Web program-peformance-optimization
Web program-peformance-optimizationWeb program-peformance-optimization
Web program-peformance-optimizationxiaojueqq12345
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the CloudWesley Beary
 
Getting Started with Spark Structured Streaming - Current 22
Getting Started with Spark Structured Streaming - Current 22Getting Started with Spark Structured Streaming - Current 22
Getting Started with Spark Structured Streaming - Current 22Dustin Vannoy
 

Similar a Asynchronous Threads in Lasso 8.5 (20)

Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Real-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioReal-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.io
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
 
Analysis bottleneck in J2EE application
Analysis bottleneck in J2EE applicationAnalysis bottleneck in J2EE application
Analysis bottleneck in J2EE application
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Application
 
Os Gopal
Os GopalOs Gopal
Os Gopal
 
How we setup Rsync-powered Incremental Backups
How we setup Rsync-powered Incremental BackupsHow we setup Rsync-powered Incremental Backups
How we setup Rsync-powered Incremental Backups
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppet
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
Hadoop spark performance comparison
Hadoop spark performance comparisonHadoop spark performance comparison
Hadoop spark performance comparison
 
Apache Traffic Server
Apache Traffic ServerApache Traffic Server
Apache Traffic Server
 
Pegasus - automate, recover, and debug scientific computations
Pegasus - automate, recover, and debug scientific computationsPegasus - automate, recover, and debug scientific computations
Pegasus - automate, recover, and debug scientific computations
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
 
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
 
Web program-peformance-optimization
Web program-peformance-optimizationWeb program-peformance-optimization
Web program-peformance-optimization
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Getting Started with Spark Structured Streaming - Current 22
Getting Started with Spark Structured Streaming - Current 22Getting Started with Spark Structured Streaming - Current 22
Getting Started with Spark Structured Streaming - Current 22
 

Último

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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 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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Asynchronous Threads in Lasso 8.5

  • 1. Advanced Track: Asynchronous Threads Bil Corry lasso.pro
  • 2. What Are Async Threads? Code that executes in parallel to the currently processing page.
  • 3.
  • 4.
  • 5. Web server determines the request is for Lasso and passes it to the Lasso connector
  • 6. Lasso connector communicates with Lasso Server and sends the request
  • 7. Lasso Server parses request, replies to Lasso connector
  • 8. Lasso connector replies to web server
  • 9. Web server replies to browser
  • 10.
  • 11.
  • 13. It is terminated for taking too long
  • 14.
  • 15.
  • 16. It will also not have access to the variables of the page that created it.
  • 17. All file paths must be absolute from the hard disk root – [include] does not work
  • 18.
  • 19. An async thread will execute according to its priority and the load on Lasso
  • 20. Basic Example Async threads are surrounded by curly-braces and initiated using ->asasyn c: [{'Hello World'}->asasync] The above code doesn't show anything in the browser, but it does run asynchronously.
  • 21. Sending Data to Async Thread ->asasync allows you to add params to pass into the async thread [{ var('p1') = params->find('p1')->get(1)->value } ->asasync(-params=array('p1'=1, 'p2'=2))] Can also use globals (or other shared resources), but take care to correctly send the right message to the right thread and use [thread_atomic] to keep access to the global thread-safe
  • 22. Template For Copying Vars To Async Thread <?LassoScript // from: http://www.lassotech.com/async // stuff on your page not async here... // -------------- BEGIN OF ASYNC CODE -------------- { // -------------- BEGIN OF ASYNC CODE -------------- // -------------------- // process async! // -------------------- // // NOTE: Code below this point is processed in it's own thread! // Lasso_ExecutionTimeLimit(60 * 60); // in seconds, set this to something reasonable Thread_SetPriority(Thread_GetCurrentID, Thread_Priority_Low); // set priority // recreate vars - this makes all the vars on the page available to the async thread iterate: params->(find:'-vars')->(get:1)->value, local:'var'; (var: #var->name) = #var->value; /iterate; // do stuff here that you want in it's own thread... // -------------- END OF ASYNC CODE -------------- }->(asasync: -params=(array: '-vars' = vars)); // -------------- END OF ASYNC CODE -------------- // do more stuff on the current page... ?>
  • 23. Creating Context To create context within async threads, use variables to store the context of the current page (such as client_headers, file path, action_params) and use the template to pass the context into the async thread.
  • 24.
  • 25.
  • 26. Task does not need to return data for the enduser to view
  • 27. Task does not have to be finished by the time the concurrent page is served
  • 28. Example of Off-Loading a Task Page originally created related records and made the enduser wait: [ loop(500); // create related record inline(-sql=”INSERT INTO mytable (id,this,that) VALUES (”+integer($userid)+”,”+integer($this)+”,”+integer($that)+”)”); /loop; 'Thanks for waiting!'; ]
  • 29. Example of Off-Loading a Task (cont) Page now off-loads the related records creation and response much quicker to the enduser: <?LassoScript // from: http://www.lassotech.com/async // -------------- BEGIN OF ASYNC CODE -------------- { // -------------- BEGIN OF ASYNC CODE -------------- Lasso_ExecutionTimeLimit(60 * 60); // in seconds, set this to something reasonable Thread_SetPriority(Thread_GetCurrentID, Thread_Priority_Low); // set priority // recreate vars - this makes all the vars on the page available to the async thread iterate: params->(find:'-vars')->(get:1)->value, local:'var'; (var: #var->name) = #var->value; /iterate; loop(500); // create related record inline(-sql=”INSERT INTO mytable (id,this,that) VALUES (”+integer($userid)+”,”+integer($this)+”,”+integer($that)+”)”); /loop; // -------------- END OF ASYNC CODE -------------- }->(asasync: -params=(array: '-vars' = vars)); // -------------- END OF ASYNC CODE -------------- 'Thanks for waiting!'; ?>
  • 30.
  • 31. Use [Lasso_ExecutionTimeLimit(0)] to permit the thread to run continuously
  • 32. Can use a global to use as a switch to shut down the thread – [while(global('on'))] – just be sure to use [thread_atomic] to make it thread-safe
  • 33.
  • 34. Example of a Recurring Event Creating a thread to watch a folder for new files to process: [{ Lasso_ExecutionTimeLimit(0); // run forever Thread_SetPriority(Thread_GetCurrentID, Thread_Priority_Low); // low priority while(true); iterate(file_listdirectory('///path/from/disk/root/'),local('file')); // do something with #file /iterate; Sleep(1000*60*10); // sleep 10 minutes (in milliseconds) /while; }->asasync] This would be placed in your LassoStartup folder.
  • 35.
  • 37. Send debug messages to an external source (file, database, etc.)
  • 38. Test Outside of Async Easiest testing method, comment out the ->asasync container and try running your code, does it work? For recurring event threads, you'll have to limit the number of loop_counts and shorten the sleep: [//{ Lasso_ExecutionTimeLimit(0); // run forever Thread_SetPriority(Thread_GetCurrentID, Thread_Priority_Low); // low priority while(true); loop_count > 10 ? loop_abort; iterate(file_listdirectory('///path/from/disk/root/'),local('file')); // do something with #file /iterate; Sleep(1000*60*2); // sleep 2 minutes (in milliseconds) /while; //}->asasync ]
  • 39. Trapping for Errors Place async code within [protect] to log errors: [{ Lasso_ExecutionTimeLimit(0); // run forever Thread_SetPriority(Thread_GetCurrentID, Thread_Priority_Low); // low priority protect; handle_error; log_critical('Folder watcher encounter an error: '+error_msg); /handle_error; while(true); iterate(file_listdirectory('///path/from/disk/root/'),local('file')); // do something with #file /iterate; Sleep(1000*60*10); // sleep 10 minutes (in milliseconds) /while; /protect; }->asasync]
  • 40.
  • 44. Email