Multiprocessing Client connection, send call is blocking when multiple threads try to connect to IPC Server which is offline/down/not running

Open
#101,405 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start at the multiprocessing.connection.Client entry point and reproduce the issue on Windows 10 with three threads while the IPC server is offline. Trace why only one call returns the connection-refused exception; done means every thread returns instead of remaining blocked, with regression coverage for this scenario.

Written by the indexing model from the issue text.

Description

topic-multiprocessing type-bug

Bug report

When multiple threads access send call of multiprocessing Client to connect to server via IPC, the threads are blocked forever. This occurs when IPC server is down and the client tries to connect to server.

CODE:

from multiprocessing.connection import Client
def ipc_send(data={}):
    try:
        address = ('localhost', 56000)
        print("ipc address: ", address)
        conn = Client(address, authkey="SOMESECRET")
        conn.send(data)
        res = conn.recv()
        conn.close()
        return True
    except Exception as e:
        print(e)
    return None

As server is down, when ipc_send() is called by 3 different threads(including main thread), suprisingly only one thread has returned None with exception: [WinError 10061] No connection could be made because the target machine actively refused it.

It is trivial that Error would be connection refused as server is down, but only one thread has thrown the error and rest of the 2 threads are possibly blocked at

conn = Client(address, authkey="SOMESECRET")

Your environment

Python 3.8.8
OS: Windows 10.

Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.