Permalink
Browse files

use a cancel-specific timer thread for SqlQuery cancelAsynchronously

  • Loading branch information...
1 parent 79a6911 commit 9c2f37c0ee2ee48b48988bee66e45b23ba51b3e2 @freels freels committed Sep 5, 2010
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/main/scala/com/twitter/querulous/query/SqlQuery.scala
@@ -42,7 +42,12 @@ object NullValues {
def apply(typeVal: Int) = nullTypes(typeVal)
}
+private object QueryCancellation {
+ val cancelTimer = new java.util.Timer("Query cancellation timer", true)
+}
+
class SqlQuery(connection: Connection, query: String, params: Any*) extends Query {
+ import QueryCancellation._
val statement = buildStatement(connection, query, params: _*)
@@ -78,9 +83,7 @@ class SqlQuery(connection: Connection, query: String, params: Any*) extends Quer
override def run() {
try {
// FIXME make duration configurable
- // FIXME use cancel specific timer, so that blocks in
- // the global timeout thread do not affect cancel timeouts
- Timeout(new com.twitter.xrayspecs.Duration(200)) {
+ Timeout(cancelTimer, new com.twitter.xrayspecs.Duration(200)) {
try {
// start by trying the nice way
statement.cancel()

0 comments on commit 9c2f37c

Please sign in to comment.