11
11
12
12
# Necessary for static type checking
13
13
if False : # flake8: noqa
14
- from typing import List , Union , Any , Optional , Hashable , Dict , Tuple
14
+ from typing import List , Union , Any , Optional , Hashable , Dict , Tuple , Type
15
15
from ..type .schema import GraphQLSchema
16
16
17
17
@@ -165,6 +165,7 @@ def __init__(
165
165
fallback_backend = None , # type: Optional[GraphQLBackend]
166
166
cache_map = None , # type: Optional[Dict[Hashable, GraphQLDocument]]
167
167
use_consistent_hash = False , # type: bool
168
+ worker_class = AsyncWorker , # type: Type[AsyncWorker]
168
169
):
169
170
# type: (...) -> None
170
171
if not backend :
@@ -180,6 +181,7 @@ def __init__(
180
181
raise Exception ("Need to provide a fallback backend" )
181
182
182
183
self .fallback_backend = fallback_backend # type: ignore
184
+ self .worker_class = worker_class
183
185
super (GraphQLDeciderBackend , self ).__init__ (
184
186
backend , cache_map = cache_map , use_consistent_hash = use_consistent_hash
185
187
)
@@ -191,7 +193,7 @@ def queue_backend(self, key, schema, request_string):
191
193
def get_worker (self ):
192
194
# type: () -> AsyncWorker
193
195
if self ._worker is None or not self ._worker .is_alive ():
194
- self ._worker = AsyncWorker ()
196
+ self ._worker = self . worker_class ()
195
197
return self ._worker
196
198
197
199
def document_from_string (self , schema , request_string ):
0 commit comments