Skip to content

Commit 2df726e

Browse files
committed
Handle erlang.ProcessError in _run_and_send
Catch ProcessError when sending async task results back to caller. If the caller process is gone, silently ignore the send failure.
1 parent 5921a91 commit 2df726e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

priv/_erlang_impl/_loop.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,10 +1339,19 @@ async def _run_and_send(coro, caller_pid, ref):
13391339

13401340
try:
13411341
result = await coro
1342-
erlang.send(caller_pid, (async_result, ref, (ok, result)))
1342+
try:
1343+
erlang.send(caller_pid, (async_result, ref, (ok, result)))
1344+
except erlang.ProcessError:
1345+
pass # Caller gone, nothing to do
13431346
except asyncio.CancelledError:
1344-
erlang.send(caller_pid, (async_result, ref, (error, 'cancelled')))
1347+
try:
1348+
erlang.send(caller_pid, (async_result, ref, (error, 'cancelled')))
1349+
except erlang.ProcessError:
1350+
pass # Caller gone, nothing to do
13451351
except Exception as e:
13461352
import traceback
13471353
tb = traceback.format_exc()
1348-
erlang.send(caller_pid, (async_result, ref, (error, f'{type(e).__name__}: {e}\n{tb}')))
1354+
try:
1355+
erlang.send(caller_pid, (async_result, ref, (error, f'{type(e).__name__}: {e}\n{tb}')))
1356+
except erlang.ProcessError:
1357+
pass # Caller gone, nothing to do

0 commit comments

Comments
 (0)