Create a new shared object and return its id
(self, c, typeid, /, *args, **kwds)
| 375 | self.stop_event.set() |
| 376 | |
| 377 | def create(self, c, typeid, /, *args, **kwds): |
| 378 | ''' |
| 379 | Create a new shared object and return its id |
| 380 | ''' |
| 381 | with self.mutex: |
| 382 | callable, exposed, method_to_typeid, proxytype = \ |
| 383 | self.registry[typeid] |
| 384 | |
| 385 | if callable is None: |
| 386 | if kwds or (len(args) != 1): |
| 387 | raise ValueError( |
| 388 | "Without callable, must have one non-keyword argument") |
| 389 | obj = args[0] |
| 390 | else: |
| 391 | obj = callable(*args, **kwds) |
| 392 | |
| 393 | if exposed is None: |
| 394 | exposed = public_methods(obj) |
| 395 | if method_to_typeid is not None: |
| 396 | if not isinstance(method_to_typeid, dict): |
| 397 | raise TypeError( |
| 398 | "Method_to_typeid {0!r}: type {1!s}, not dict".format( |
| 399 | method_to_typeid, type(method_to_typeid))) |
| 400 | exposed = list(exposed) + list(method_to_typeid) |
| 401 | |
| 402 | ident = '%x' % id(obj) # convert to string because xmlrpclib |
| 403 | # only has 32 bit signed integers |
| 404 | util.debug('%r callable returned object with id %r', typeid, ident) |
| 405 | |
| 406 | self.id_to_obj[ident] = (obj, set(exposed), method_to_typeid) |
| 407 | if ident not in self.id_to_refcount: |
| 408 | self.id_to_refcount[ident] = 0 |
| 409 | |
| 410 | self.incref(c, ident) |
| 411 | return ident, tuple(exposed) |
| 412 | |
| 413 | def get_methods(self, c, token): |
| 414 | ''' |