hupili / snsapi

Cross platform middleware for Social Networking Services: Twitter, Facebook, SinaWeibo, Renren, RSS, Email, Sqlite, ... (more coming)
http://snsapi.ie.cuhk.edu.hk
159 stars 53 forks source link

Asynchronous Message Queue #25

Open hupili opened 11 years ago

hupili commented 11 years ago

With the increasing number of channels, synchronous call to all methods causes larger and larger delay. Before it exceeds human tolerable span, we should consider an asynchronous message queue.

The queue:

Requires experienced Python developer and one who is familiar with SNSAPI framework.

Welcome any prototyping and restructuring effort to make the queue easy to implement.

iptux commented 11 years ago

maybe, wrapper synchronous calls into threads is another, but poor, solution for these DELAYs https://github.com/iptux/snsapi/commit/db24686e73ce31fa186c7aacda9d515ad47dabe5

i'm considering whether to make a pull request, it havn't solve the underlying problem

hupili commented 11 years ago

Nice commit!

I think this is the current best solution for upper layer apps. However, it is not suitable to put that commit in the snspocket.

Instead of method by method modification, my suggestion is:

The use cases are then:

This way looks better for me before we have such async-queue facility. What do you think?

hupili commented 11 years ago

One prototype is implemented in sina-automator

It implements a leaky bucket for resource management. The rate_limit decorator also has callback support. For resource management within one channel, the sina-automator's lbucket suffices.

One still missing piece is the ability to coordinate resources between different channels. Note that when there are more and more channels, apps may want to simultaneously request them. Resources should be considered across channels, i.e. "Support per-platform / per-account / per-key locking.".

hupili commented 10 years ago

This feature will gradually enter SNSAPI starting from v0.7 .

@fqj1994 , please place a warning log message to notify users about possible interfaces changes of async related stuffs.