dnephin/TracAdvancedSearchPlugin — pull request #27 by t2y (2014-02-27 10:06:43+00:00)
Title: fixed to exit AsyncSolrIndexer thread when ticket is updated by trac-admin command

I found a critical bug when AsyncSolrIndexer is used with trac-admin command, and then this patch is quick hack to fix and works for our environment.

Essentially, Trac instance should have the state about trac-admin, however I'm not sure how to get it. This patch inspects the frame object on stack and find `execute_command` function calling from AdminCommandManager.

Indexing process for fulltext search is called by some trac-admin command. For example, one of them, `changeset` sub command with commit hook.

```sh
$ trac-admin TRAC_ENV changeset added REPOSITORY CHANGESET
```

After added the changeset, Trac try to update ticket's comment by commit_updater and AsyncSolrIndexer is instantiated to call the upsert method. Then, AsyncSolrIndexer blocks to get items from queue (see below) . As the result, trac-admin command never exited and its process has remained forever.

https://github.com/dnephin/TracAdvancedSearchPlugin/blob/master/tracadvsearch/backend.py#L137