Hello,
I have a minor issue with ProcessPoolExecutors that I wasn't able to find a solution to.
I am running an aiohttp server that needs to do some short-term cpu-bound function calls (bcrypt).
So I decided to use one long-running ProcessPoolExecutor object for this to keep the main event loop free to respond to requests (since I need to account for a large volume of bcrypt calls).
My main server looks something like:
class Server:
def __init__(self):
self.process_pool = ProcessPoolExecutor(...)
def run(self):
try:
# exiting this context manager will call .shutdown()
with self.process_pool:
...
except (KeyboardInterrupt, SystemExit):
...
I am submitting tasks from request handlers like:
loop = asyncio.get_running_loop()
loop.run_in_executor(process_pool, ...)
the problem is when this gets interrupted with KeyboardInterrupt, I catch it and everything closes cleanly but these child processes all give out a messy traceback, which I will post in a below message.
The traceback repeats once per child process.
Please can someone explain to me why this is happening and help me fix it? Any help is much appreciated.