MCPcopy Create free account
hub / github.com/celery/celery / RPCBackend

Class RPCBackend

celery/backends/rpc.py:154–449  ·  view source on GitHub ↗

Base class for the RPC result backend.

Source from the content-addressed store, hash-verified

152
153
154class RPCBackend(base.Backend, AsyncBackendMixin):
155 """Base class for the RPC result backend."""
156
157 Exchange = kombu.Exchange
158 Producer = kombu.Producer
159 ResultConsumer = ResultConsumer
160
161 #: Exception raised when there are too many messages for a task id.
162 BacklogLimitExceeded = BacklogLimitExceeded
163
164 persistent = False
165 supports_autoexpire = True
166 supports_native_join = True
167
168 retry_policy = {
169 'max_retries': 20,
170 'interval_start': 0,
171 'interval_step': 1,
172 'interval_max': 1,
173 }
174
175 class Consumer(kombu.Consumer):
176 """Consumer that requires manual declaration of queues."""
177
178 auto_declare = False
179
180 class Queue(kombu.Queue):
181 """Queue that never caches declaration."""
182
183 can_cache_declaration = False
184
185 def __init__(self, app, connection=None, exchange=None, exchange_type=None,
186 persistent=None, serializer=None, auto_delete=True, **kwargs):
187 super().__init__(app, **kwargs)
188 conf = self.app.conf
189 self._connection = connection
190 self._out_of_band = {}
191 self.persistent = self.prepare_persistent(persistent)
192 self.delivery_mode = 2 if self.persistent else 1
193 exchange = exchange or conf.result_exchange
194 exchange_type = exchange_type or conf.result_exchange_type
195 self.exchange = self._create_exchange(
196 exchange, exchange_type, self.delivery_mode,
197 )
198 self.serializer = serializer or conf.result_serializer
199 self.auto_delete = auto_delete
200 self.result_consumer = self.ResultConsumer(
201 self, self.app, self.accept,
202 self._pending_results, self._pending_messages,
203 )
204 if register_after_fork is not None:
205 register_after_fork(self, _on_after_fork_cleanup_backend)
206
207 def _after_fork(self):
208 # clear state for child processes.
209 for mapping in self._pending_results:
210 mapping.clear()
211 self._out_of_band.clear()

Callers 6

get_backendMethod · 0.90
setup_methodMethod · 0.90
test_oid_threadsMethod · 0.90
setup_methodMethod · 0.90

Calls

no outgoing calls

Tested by 6

get_backendMethod · 0.72
setup_methodMethod · 0.72
test_oid_threadsMethod · 0.72
setup_methodMethod · 0.72