MCPcopy
hub / github.com/celery/celery / subclass_with_self

Method subclass_with_self

celery/app/base.py:1256–1289  ·  view source on GitHub ↗

Subclass an app-compatible class. App-compatible means that the class has a class attribute that provides the default app it should use, for example: ``class Foo: app = None``. Arguments: Class (type): The app-compatible class to subclass. na

(self, Class, name=None, attribute='app',
                           reverse=None, keep_reduce=False, **kw)

Source from the content-addressed store, hash-verified

1254 )
1255
1256 def subclass_with_self(self, Class, name=None, attribute='app',
1257 reverse=None, keep_reduce=False, **kw):
1258 """Subclass an app-compatible class.
1259
1260 App-compatible means that the class has a class attribute that
1261 provides the default app it should use, for example:
1262 ``class Foo: app = None``.
1263
1264 Arguments:
1265 Class (type): The app-compatible class to subclass.
1266 name (str): Custom name for the target class.
1267 attribute (str): Name of the attribute holding the app,
1268 Default is 'app'.
1269 reverse (str): Reverse path to this object used for pickling
1270 purposes. For example, to get ``app.AsyncResult``,
1271 use ``"AsyncResult"``.
1272 keep_reduce (bool): If enabled a custom ``__reduce__``
1273 implementation won't be provided.
1274 """
1275 Class = symbol_by_name(Class)
1276 reverse = reverse if reverse else Class.__name__
1277
1278 def __reduce__(self):
1279 return _unpickle_appattr, (reverse, self.__reduce_args__())
1280
1281 attrs = dict(
1282 {attribute: self},
1283 __module__=Class.__module__,
1284 __doc__=Class.__doc__,
1285 **kw)
1286 if not keep_reduce:
1287 attrs['__reduce__'] = __reduce__
1288
1289 return type(name or Class.__name__, (Class,), attrs)
1290
1291 def _rgetattr(self, path):
1292 return attrgetter(path)(self)

Callers 11

create_task_clsMethod · 0.95
WorkerMethod · 0.95
WorkControllerMethod · 0.95
BeatMethod · 0.95
AsyncResultMethod · 0.95
ResultSetMethod · 0.95
GroupResultMethod · 0.95
inspectMethod · 0.80
ReceiverMethod · 0.80
DispatcherMethod · 0.80
StateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected