王珺 wrote:
Suppose io_operation() takes 3 seconds, then how can I write something likefuture = io_operation() print('Start') time.sleep(1) print('Something') time.sleep(2) print(future.result()) that print 'Start' immediately and the result of io_operation() 3 seconds later.
Yes, Python can do this, but you probably need to use real threads. The only exception would be if io_operation() were something you could fire off with a single system call that's guaranteed not to block, and then wait for the result later. Opportunities for things like that are rare in unix. (Windows might be different, I'm not sure.) -- Greg -- https://mail.python.org/mailman/listinfo/python-list
