4 ms·
Since most operations in the IMVU client are bound on disk or the network, we implemented an asynchronous programming model based on futures and coroutines (Pyt
by chadaustin 17y ago
Since most operations in the IMVU client are bound on disk or the network, we implemented an asynchronous programming model based on futures and coroutines (Python generators), which we've recently extended with queues, actors, and more explicit cancellation functionality. This system has grown intuitive enough that new engineers can grasp it fairly quickly, and there are very few gotchas or common mistakes.
In our network-connected, cpu-is-millions-of-times-faster-than-disk world, asynchronous programming is really important for building a responsive desktop application.
One of our engineers blogged about the task system at http://thespeedbump.livejournal.com/63798.html http://thespeedbump.livejournal.com/63798.html and http://thespeedbump.livejournal.com/64053.html http://thespeedbump.livejournal.com/64053.html
The source is available at http://imvu.svn.sourceforge.net/viewvc/imvu/imvu_open_source/imvu.task/imvu/ http://imvu.svn.sourceforge.net/viewvc/imvu/imvu_open_source...
- chadaustin 17y agop.s. we're doubling our engineering team this year. If interesting programming models are your thing, I'd love to chat! http://www.imvu.com/jobs/index_eng.php http://www.imvu.com/jobs/index_eng.php chad@imvu.com
- yummyfajitas 17y agoJust to elaborate on what you are saying, I'll write a pythonic version of the handleBlogPostRequest described in the article. This example is a line by line copy of the one in the post, no real library is used. def handleBlogPostRequest(request, response, postSlug): db = yield DBClient() post = yield getBlogPost(postSlug) comments = yield db.getComments(post.id) html = template.render('blog/post.html', {'post': post, 'comments': comments}); response.write(html) response.close() The 'yield' command turns the result of handleBlogPostRequest into a generator. When you "yield getBLogPost(...)", the generator returns a request to the database for a blogpost. When it is ready, the framework passes it back into the generator and assigns the result to post.