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

Offen
#101,405 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
42/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
backend, networking

Rechercherichtung

Beginne am Einstiegspunkt multiprocessing.connection.Client und reproduziere das Problem unter Windows 10 mit drei Threads, während der IPC-Server offline ist. Verfolge, warum nur ein Aufruf die Verbindungsablehnungs-Exception zurückgibt; als erledigt gilt die Aufgabe, wenn jeder Thread zurückkehrt, anstatt blockiert zu bleiben, und eine Regressionstestabdeckung für dieses Szenario vorhanden ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
558

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python/cpython

Alle Issues in python/cpython

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.