Module introduit dans python3.4 permettant l’asynchrone sans de code spaghetti
Javascript!
Des callback de callback de callback
$.get('/', function(data) {
$.post('/', function(data) {
setTimeout(function() { $.get('/timeout', function(data) {
...
}, 1000)
}
}
}
Pas de callback. Lecture linéaire compréhensible.
resp = yield from http.get('/')
resp = yield from http.post('/', (yield from resp.body))
yield from asyncio.sleep(.1)
resp = yield from http.get('/timeout')
2015-06-12 09:00:00 INFO alarm matin launched
2015-06-12 09:00:00 INFO ison {'names': ['gawel']}
2015-06-12 09:00:00 INFO whois {'idle': '31821', ...}
2015-06-12 09:00:00 INFO Ring matin for gawel
2015-06-12 09:00:01 INFO irc3.alarm.gawel is ringing
2015-06-12 09:00:16 INFO Hangup <Message ...> after 15s
2015-06-12 09:00:16 INFO irc3.alarm.gawel is ringing
2015-06-12 09:00:16 INFO Hangup <Message ...> after 0s
Check le pseudo, l’idle, puis sonne. Raccroche au bout de 15s.
Ne réveille pas si on est réveillé. Tadaah!