import asyncio import multiprocessing def error_callback(e): if type(e) is asyncio.IncompleteReadError: print("As expected we got a IncompleteReadError. \nPartial read content is {}".format(e.partial)) def setup(): loop = asyncio.get_event_loop() future = asyncio.ensure_future(func()) res, err = loop.run_until_complete(future) print(res) print(err) async def func(): reader, writer = await asyncio.open_connection("example.com", 80) writer.write(b"GET / HTTP/1.1\r\n\r\n") result = await reader.readuntil(b"non_existing_delimiter") print("This should never be printed. Result: " + result) pool = multiprocessing.Pool(2) pool.apply_async(func=setup, error_callback=error_callback) pool.close() pool.join()