Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
Максим Щепелин. "Unittesting. Как?"
Next
Download to read offline and view in fullscreen.

0

Share

Download to read offline

Про асинхронность / Максим Щепелин / Web Developer Wargaming

Download to read offline

Речь пойдет о двух языках: Python и Javascript. Максим расскажет об асинхронной работе Python и Javascript, что даст возможность слушателям приобщиться к особой касте разработчиков, работающих с Twisted.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Про асинхронность / Максим Щепелин / Web Developer Wargaming

  1. 1. Asynchronous programming JS and python inside Maxim Schepelin
  2. 2. Contents ● Python. ● What is call stack? ● Where callbacks come from? ● How asynchronous code execution works? ● Summary
  3. 3. Code: Call stack: def multiply(x, y): return x * y def square(x): return multiply(x, x) def print_result(n): result = square(n) sys.stdout.write(result) if __name__ == '__main__': print_result(4) multiply square print_result main
  4. 4. Code: Call stack: def foo(): foo() if __name__ == '__main__': foo() foo foo foo foo foo foo foo main RuntimeError: maximum recursion depth exceeded
  5. 5. Contents ● Python. ● What is call stack? ● Where callbacks come from? ● How asynchronous code execution works? ● Summary
  6. 6. Code: Call stack: console.log(1); console.log(2); setTimeout(function ( ) { console.log(4); }, 500); console.log(3); csoentTsiomlee.olougt anonymous main func
  7. 7. Code: Call stack: console.log(1); console.log(2); setTimeout(function ( ) { console.log(4); }, 500); console.log(3); csoentTsiomlee.olougt anonymous main func Browser engine: Timer(cb) Callback queue: callback 1 2 3
  8. 8. Contents ● Python. ● What is call stack? ● Where callbacks come from? ● How asynchronous code execution works? ● Summary
  9. 9. Asynchronous workflow Call stack Event-loop Async call External API Callback queue
  10. 10. Code: Call stack: console.log(1); console.log(2); setTimeout(function ( ) { console.log(4); }, 0); console.log(3); csoentTsiomlee.olougt anonymous main func Browser engine: Timer(cb) Callback queue: callback 1 2 3
  11. 11. Callbacks are invoked only when call stack is emtpy!
  12. 12. Contents ● Python. ● What is call stack? ● Where callbacks come from? ● How asynchronous code execution works? ● Summary
  13. 13. Summary ● Asynchromous != multithreading ● Heavy things blocks the event-loop ● It’s still single thread
  14. 14. Q&A schepelin Maxim Schepelin

Речь пойдет о двух языках: Python и Javascript. Максим расскажет об асинхронной работе Python и Javascript, что даст возможность слушателям приобщиться к особой касте разработчиков, работающих с Twisted.

Views

Total views

1,076

On Slideshare

0

From embeds

0

Number of embeds

5

Actions

Downloads

7

Shares

0

Comments

0

Likes

0

×