diff options
author | Matthew Newhook <matthew@zeroc.com> | 2015-03-21 15:35:40 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2015-03-21 15:35:40 -0230 |
commit | 630a37d2fe66f24518299e705f958b571803c522 (patch) | |
tree | 969723791bdc4d73bb099c19d45554d0ca241ad9 /python/test/Ice/application/Client.py | |
parent | Fix some README.md markdown formatting (diff) | |
download | ice-630a37d2fe66f24518299e705f958b571803c522.tar.bz2 ice-630a37d2fe66f24518299e705f958b571803c522.tar.xz ice-630a37d2fe66f24518299e705f958b571803c522.zip |
py -> python
rb -> ruby
objc -> objective-c
cs -> csharp
Diffstat (limited to 'python/test/Ice/application/Client.py')
-rwxr-xr-x | python/test/Ice/application/Client.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/python/test/Ice/application/Client.py b/python/test/Ice/application/Client.py new file mode 100755 index 00000000000..500c03395b0 --- /dev/null +++ b/python/test/Ice/application/Client.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys, Ice, time + +class Client(Ice.Application): + def interruptCallback(self, sig): + print("handling signal " + str(sig)) + + # SIGINT interrupts time.sleep so a custom method is needed to + # sleep for a given interval. + def sleep(self, interval): + start = time.time() + while True: + sleepTime = (start + interval) - time.time() + if sleepTime <= 0: + break + time.sleep(sleepTime) + + def run(self, args): + self.ignoreInterrupt() + print("Ignore CTRL+C and the like for 5 seconds (try it!)") + self.sleep(5) + + self.callbackOnInterrupt() + + self.holdInterrupt() + print("Hold CTRL+C and the like for 5 seconds (try it!)") + self.sleep(5) + + self.releaseInterrupt() + print("Release CTRL+C (any held signals should be released)") + self.sleep(5) + + self.holdInterrupt() + print("Hold CTRL+C and the like for 5 seconds (try it!)") + self.sleep(5) + + self.callbackOnInterrupt() + print("Release CTRL+C (any held signals should be released)") + self.sleep(5) + + self.shutdownOnInterrupt() + print("Test shutdown on destroy. Press CTRL+C to shutdown & terminate") + self.communicator().waitForShutdown() + + print("ok") + return False + +app = Client() +sys.exit(app.main(sys.argv)) |