Question: Someone might have already solved this problem. I have a need for a Python based UDP interface which returns results from a DB query. The DB is limited to providing only 500 queries per 8 hour period. Here is my logic it seems to sort of work.

But I really have a moving windows of 8 hours which means I can soon query the DB within a few seconds. I am right at the limit basically. Anyone has a clever reuseable code I can use for this?

```
#!/usr/bin/env python
import SocketServer
import sys,os,httplib,urllib,multiprocessing,time
import syslog
import sqlite3 as lite
syslog.openlog(sys.argv[0],syslog.LOG_PID,syslog.LOG_USER)
count_d=0
stime=int(time.time())

def oprocess(vars):
    global count_d,stime
    dtime=int(time.time())-stime
    score="Unknown"
    if count_d > 500:
        if dtime < 28800:
            syslog.syslog("Exceeded q limit "+str(dtime)+","+str(count))
            return "Unknown"
        else: # Reset the clock
            stime=time.time()
            count_d=0
    data=dbh.do("SELECT...") # Some DB query
    if data != None:
        count_d=count_d+1
        return data

```

Thanks
Vijay

Answer: 
For a quick look it seems you missed `default_searchable` setting in your AndroidManifest.

Under activity setting for MainActivity, you should add this

```
<meta-data
  android:name="android.app.default_searchable"
  android:value=".WebActivity" />

```
Make sure your `searchables.xml` file is in the correct location (i.e, in your `res/xml/` folder) and that the same file does not contain any errors - otherwise you will find that `(SearchManager)getSystemService(Context.SEARCH_SERVICE).getSearchableInfo(componentName)` will return null, breaking your search functionality.

(Also, ensure you set `componentName` in the appropriate manner, because the example shown in the Android guide is for only when you are making searches and displaying searches in the same Activity.)