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.

classification
Title: multiprocessing.managers.SyncManager managed object creation fails when started outside of invoked file
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: jnoller Nosy List: asksol, etzool, jnoller
Priority: normal Keywords:

Created on 2009-12-10 20:33 by etzool, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg96215 - (view) Author: Eric (etzool) Date: 2009-12-10 20:32
I am attempting to create a multiprocessing.SyncManager subclass
instance, register a test class with it, start the manager, and
instantiate the test class.  The example I'm providing here is basically
equivalent, and illustrates the same problem (example code is at the
bottom of this message).

This works without issue as long as the manager is started in the file
you actually invoke from the command line.  Handled in exactly the same
way, however, with the call to the SyncManager instance's start method
made in an included file, attempting to instantiate anything, including
built-in list() and dict() objects, via the manager causes script to
hang indefinitely.

Output on ctrl+c breaking seems to indicate the call may be hanging in
the challenge process.

Invocation and output (starting/started are wrapped around the start()
call; creating/created are wrapped around the manager's registered
object instantiation):

$ python test.py 
starting...
...started
creating...
^CTraceback (most recent call last):
  File "test.py", line 6, in <module>
    obj = test_manager.TC()
  File "/usr/lib64/python2.6/multiprocessing/managers.py", line 634, in temp
    token, exp = self._create(typeid, *args, **kwds)
  File "/usr/lib64/python2.6/multiprocessing/managers.py", line 532, in
_create
    conn = self._Client(self._address, authkey=self._authkey)
  File "/usr/lib64/python2.6/multiprocessing/connection.py", line 140,
in Client
    answer_challenge(c, authkey)
  File "/usr/lib64/python2.6/multiprocessing/connection.py", line 372,
in answer_challenge
    message = connection.recv_bytes(256)         # reject large message
KeyboardInterrupt


test.py:

from test_inc import test_manager

print "creating..."
obj = test_manager.dict()
print "...created"

test_inc.py:

from multiprocessing.managers import SyncManager

test_manager = SyncManager()	
print "starting..."
test_manager.start()
print "...started"

Environment: Linux 2.6.28-gentoo-r5 #4 SMP x86_64 Intel(R) Core(TM)2 Duo
CPU T5470 @ 1.60GHz GenuineIntel GNU/Linux

Version: Python 2.6.4

Apologies if this is my failure to understand how the library (or even
Python) works, but it seems quite odd that this would be expected behavior.
msg119501 - (view) Author: Ask Solem (asksol) (Python committer) Date: 2010-10-24 08:59
I can't seem to reproduce this on trunk...
msg140511 - (view) Author: Eric (etzool) Date: 2011-07-16 23:58
Tested in 2.6.6 on Gentoo and 2.7.1 on Ubuntu (Server); this behavior is no longer present when using the provided code.

Hopefully this means the original issue has been solved; I haven't touched the code that revealed it since around the time I filed this originally.

If someone can confirm that the test code works in whatever versions of Python 3 are current, please go ahead and close this.
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51723
2012-06-08 12:21:31sbtsetstatus: open -> closed
resolution: out of date
stage: resolved
2011-07-16 23:58:33etzoolsetstatus: pending -> open
versions: + Python 3.1, Python 3.2, Python 3.3, Python 3.4, - Python 2.6
2011-07-16 23:58:06etzoolsetstatus: open -> pending

messages: + msg140511
versions: + Python 2.6, - Python 3.1, Python 2.7, Python 3.2
2010-10-24 08:59:49asksolsetnosy: + asksol
messages: + msg119501
2010-07-11 11:02:02BreamoreBoysetnosy: jnoller, etzool
components: + Library (Lib), - Extension Modules
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-12-11 01:56:15benjamin.petersonsetassignee: jnoller
2009-12-10 21:11:00r.david.murraysetpriority: normal
nosy: + jnoller
type: crash -> behavior
2009-12-10 20:33:28etzoolsettype: crash
2009-12-10 20:33:02etzoolcreate