`_pickle.PicklingError: Can't pickle <function <lambda> at 0x...>` with `ProcessPoolExecutor`.
IntermediateTroubleshootingConcurrency, async, tests, services & containers
Answer
Likely causes → Arguments and functions sent to worker processes must be picklable; lambdas, nested functions, open files, locks and boto3 clients are not.
Diagnose → The traceback names the object that failed.
Fix → Use a module-level function, pass plain data (IDs, dicts), and create clients inside the worker (a pool initializer can set them up once per process).
Prevent → Use processes only for CPU-bound work on plain data; use threads for API calls.
More on Concurrency, async, tests, services & containers
`RuntimeError: asyncio.run() cannot be called from a running event loop` in a Jupyter notebook or inside an async framework.Intermediate`RuntimeWarning: coroutine 'fetch' was never awaited` and nothing happens.BeginnerAn asyncio health-checker is no faster than a sequential loop.Advanced`Task was destroyed but it is pending!` at shutdown.Advanced`OSError: [Errno 24] Too many open files` from an asyncio scanner with 20,000 targets.IntermediateA `ThreadPoolExecutor` job finishes "successfully" but half the work is missing, with no errors logged.Intermediate