Implement time-based quotas in python
I'm not aware of any ready-made component, but it should be fairly simple to do this.
I would probably use a database table, containing two columns: user ID and timestamp. Each time a user (IP address?) wants a connection, you find all the entries with that user ID with a timestamp between now and 60 seconds ago. If it's under the limit, you add an entry and allow the connection; otherwise, you reject the connection.
I need to implement a time-based quota in my python (twisted) application.
Is there an existing module, or other implementation that I should use as a reference?
Specifically, my application needs to ratelimit connections from clients, using rules like '10 connections per minute'.
There is a Google App Engine module name 'taskqueue' that seems to fit my needs, but I am not using GAE.
Thank you.
EDIT:

platform is linux
re: iptables; it needs to be in the application b/.c the quotas will not be based on source IP address, rather some application-specific data ('clientid', for example).