1111
1212# Necessary for static type checking
1313if 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
1515 from ..type .schema import GraphQLSchema
1616
1717
@@ -165,6 +165,7 @@ def __init__(
165165 fallback_backend = None , # type: Optional[GraphQLBackend]
166166 cache_map = None , # type: Optional[Dict[Hashable, GraphQLDocument]]
167167 use_consistent_hash = False , # type: bool
168+ worker_class = AsyncWorker , # type: Type[AsyncWorker]
168169 ):
169170 # type: (...) -> None
170171 if not backend :
@@ -180,6 +181,7 @@ def __init__(
180181 raise Exception ("Need to provide a fallback backend" )
181182
182183 self .fallback_backend = fallback_backend # type: ignore
184+ self .worker_class = worker_class
183185 super (GraphQLDeciderBackend , self ).__init__ (
184186 backend , cache_map = cache_map , use_consistent_hash = use_consistent_hash
185187 )
@@ -191,7 +193,7 @@ def queue_backend(self, key, schema, request_string):
191193 def get_worker (self ):
192194 # type: () -> AsyncWorker
193195 if self ._worker is None or not self ._worker .is_alive ():
194- self ._worker = AsyncWorker ()
196+ self ._worker = self . worker_class ()
195197 return self ._worker
196198
197199 def document_from_string (self , schema , request_string ):
0 commit comments