This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients boom0192, davin, ethan.furman, pitrou, serhiy.storchaka
Date 2021-06-19.03:59:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624075163.96.0.521286536631.issue43329@roundup.psfhosted.org>
In-reply-to
Content
Here is the test, reduced and in a single script:

--- 8< --------------------------------------------------------------------
import multiprocessing.managers, os, sys, time

if __name__ == '__main__':
    address = ("127.0.0.1", 54321)

    class TestManager(multiprocessing.managers.BaseManager):
        pass

    if sys.argv[1] == 'server':

        class TestClass(object):
            def test_method(self):
                print("In test_method")
                return "TEST"

        TestManager.register("Test", TestClass)
        manager = TestManager(address = address, authkey = "1234".encode("utf-8"))
        print('waiting...')
        manager.get_server().serve_forever()

    else:

        TestManager.register("Test")

        manager = TestManager(address = address, authkey = "1234".encode("utf-8"))
        manager.connect()
        test_class = manager.Test()

        print(test_class.test_method())

        print("Kill and restart the server and press return")
        sys.stdin.readline()

        try:
            print(test_class.test_method())
        except EOFError:
            print('EOF received\n')

        # reestablish connection
        manager.connect()
        test_class = manager.Test()

        # trigger error
        print(test_class.test_method())
--- 8< --------------------------------------------------------------------

Running it in two terminals gives (only showing client side):

---------------------------------------------------------------------------
$ ./python ~/test_mp client
TEST
Kill and restart the server and press return
# hit <return>
EOF received

Traceback (most recent call last):
  File "/home/ethan/test_mp", line 45, in <module>
    print(test_class.test_method())
  File "<string>", line 2, in test_method
  File "/source/virtualenv/lib/python3.9/multiprocessing/managers.py", line 808, in _callmethod
    conn.send((self._id, methodname, args, kwds))
  File "/source/virtualenv/lib/python3.9/multiprocessing/connection.py", line 211, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/source/virtualenv/lib/python3.9/multiprocessing/connection.py", line 416, in _send_bytes
    self._send(header + buf)
  File "/source/virtualenv/lib/python3.9/multiprocessing/connection.py", line 373, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
---------------------------------------------------------------------------

The problem appears to be that the call to `manager.connect()` after the EOF is not getting a new connection, but is reusing the old one (?).  This is as far as I can take this; hopefully somebody with more multiprocessing/socket skills can take it from here.
History
Date User Action Args
2021-06-19 03:59:24ethan.furmansetrecipients: + ethan.furman, pitrou, serhiy.storchaka, davin, boom0192
2021-06-19 03:59:23ethan.furmansetmessageid: <1624075163.96.0.521286536631.issue43329@roundup.psfhosted.org>
2021-06-19 03:59:23ethan.furmanlinkissue43329 messages
2021-06-19 03:59:23ethan.furmancreate