diff --git a/Concurrence_examples/asyncio_simple_example.py b/Concurrence_examples/asyncio_simple_example.py new file mode 100644 index 0000000..3c2a508 --- /dev/null +++ b/Concurrence_examples/asyncio_simple_example.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import asyncio + +async def delayed_hello(): + print("Hello ") + await asyncio.sleep(1) + print("World!") + + +if __name__ == "__main__": + + loop = asyncio.get_event_loop() + loop.run_until_complete(delayed_hello()) + loop.close() \ No newline at end of file diff --git a/Concurrence_examples/threadpool_example.py b/Concurrence_examples/threadpool_example.py index a48e021..242c323 100644 --- a/Concurrence_examples/threadpool_example.py +++ b/Concurrence_examples/threadpool_example.py @@ -9,9 +9,9 @@ def return_after_5_secs(message): return message pool = ThreadPoolExecutor(3) - future = pool.submit(return_after_5_secs, ("hello")) + print(future.done()) sleep(5) print(future.done()) diff --git a/Concurrence_examples/threads_with_queues.py b/Concurrence_examples/threads_with_queues.py index 5d30095..921b144 100644 --- a/Concurrence_examples/threads_with_queues.py +++ b/Concurrence_examples/threads_with_queues.py @@ -33,4 +33,4 @@ task_queue.join() end_time = time.time() -print("Time: %ssecs" % (end_time - start_time)) \ No newline at end of file +print('Time: {} secs'.format(end_time - start_time)) \ No newline at end of file