I have some object, that can perform operations that take a lot of time. I need some way to interrupt it after a some timeout. My code looks like this:
def f(obj):
time.sleep(600)
obj.cancel()
t = threading.Thread(target=f, args=(obj,))
t.start()
result = obj.ExecuteLongCommand(arguments)
t.stop() # Oops!
So, is there an [easy] way to perform async
cancelable
operation? My thread t
is async
, but is not cancelable
.