diff options
author | Guido van Rossum <guido@python.org> | 1992-12-17 17:31:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-12-17 17:31:58 (GMT) |
commit | a585444f7b2c8009ccf29a6ecb76ce13587bf15c (patch) | |
tree | 60c74e2a74c2347a055fa2f3ebaf4ec314ec5866 /Demo/rpc | |
parent | 3346b6ad49e82add093c23a551872d7dd215c240 (diff) | |
download | cpython-a585444f7b2c8009ccf29a6ecb76ce13587bf15c.zip cpython-a585444f7b2c8009ccf29a6ecb76ce13587bf15c.tar.gz cpython-a585444f7b2c8009ccf29a6ecb76ce13587bf15c.tar.bz2 |
Added compatibility hacks for Python 0.9.6.
Diffstat (limited to 'Demo/rpc')
-rw-r--r-- | Demo/rpc/rpc.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Demo/rpc/rpc.py b/Demo/rpc/rpc.py index 4fbc795..71a2c1f 100644 --- a/Demo/rpc/rpc.py +++ b/Demo/rpc/rpc.py @@ -127,8 +127,13 @@ def make_auth_unix(seed, host, uid, gid, groups): return p.get_buf() def make_auth_unix_default(): - return make_auth_unix(0, socket.gethostname(), \ - os.getuid(), os.getgid(), []) + try: + from os import getuid, getgid + uid = getuid() + gid = getgid() + except ImportError: + uid = gid = 0 + return make_auth_unix(0, socket.gethostname(), uid, gid, []) # Common base class for clients @@ -259,7 +264,11 @@ class RawUDPClient(Client): p.pack_callheader(xid, self.prog, self.vers, proc, cred, verf) def do_call(self, *rest): - from select import select + try: + from select import select + except ImportError: + print 'WARNING: select not found, RPC may hang' + select = None if len(rest) == 0: bufsize = 8192 elif len(rest) > 1: @@ -271,7 +280,9 @@ class RawUDPClient(Client): count = 5 self.sock.send(call) while 1: - r, w, x = select([self.sock], [], [], timeout) + r, w, x = [self.sock], [], [] + if select: + r, w, x = select(r, w, x, timeout) if self.sock not in r: count = count - 1 if count < 0: raise RuntimeError, 'timeout' |