(self, proc, args, pack_func, unpack_func)
| 376 | self.timeout = timeout # Use None for infinite timeout |
| 377 | |
| 378 | def make_call(self, proc, args, pack_func, unpack_func): |
| 379 | if pack_func is None and args is not None: |
| 380 | raise TypeError('non-null args with null pack_func') |
| 381 | self.start_call(proc) |
| 382 | if pack_func: |
| 383 | pack_func(args) |
| 384 | call = self.packer.get_buf() |
| 385 | self.sock.sendto(call, (self.host, self.port)) |
| 386 | try: |
| 387 | from select import select |
| 388 | except ImportError: |
| 389 | print('WARNING: select not found, broadcast will hang') |
| 390 | select = None |
| 391 | BUFSIZE = 8192 # Max UDP buffer size (for reply) |
| 392 | replies = [] |
| 393 | if unpack_func is None: |
| 394 | def dummy(): pass |
| 395 | unpack_func = dummy |
| 396 | while 1: |
| 397 | r, w, x = [self.sock], [], [] |
| 398 | if select: |
| 399 | if self.timeout is None: |
| 400 | r, w, x = select(r, w, x) |
| 401 | else: |
| 402 | r, w, x = select(r, w, x, self.timeout) |
| 403 | if self.sock not in r: |
| 404 | break |
| 405 | reply, fromaddr = self.sock.recvfrom(BUFSIZE) |
| 406 | u = self.unpacker |
| 407 | u.reset(reply) |
| 408 | xid, verf = u.unpack_replyheader() |
| 409 | if xid != self.lastxid: |
| 410 | continue |
| 411 | reply = unpack_func() |
| 412 | self.unpacker.done() |
| 413 | replies.append((reply, fromaddr)) |
| 414 | if self.reply_handler: |
| 415 | self.reply_handler(reply, fromaddr) |
| 416 | return replies |
| 417 | |
| 418 | |
| 419 | # Port mapper interface |
nothing calls this directly
no test coverage detected