Author Charles McEachern
Recipients Charles McEachern
Date 2017-04-07.17:25:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491585919.25.0.878478189526.issue30018@psf.upfronthosting.co.za>
In-reply-to
Content
I'm calling the constructor of Foo, a subclass of str. Expected output:

Called Foo.__new__ with args = ('TIMESTAMP', 'INPUT0')
TIMESTAMP OUTPUT0

When I make the call using a multiprocessing.pool.ThreadPool, it works fine. But when I make the call using a multiprocessing.Pool (using the apply or apply_async method), I get:

Called Foo.__new__ with args = ('TIMESTAMP', 'INPUT0')
Called Foo.__new__ with args = ('TIMESTAMP OUTPUT0',)
Exception in thread Thread-3:
...
ValueError: Bad Foo input: ('TIMESTAMP OUTPUT0',)

That is, the object I just constructed seems to be getting shoved right back into the constructor. 

When I swap out the Foo class for the similar Goo class, which is not a str, and uses __init__ instead of __new__, I again see no problems:

Called Goo.__init__ with args = ('TIMESTAMP', 'INPUT0')
<Goo TIMESTAMP OUTPUT0>

I see this in 2.7.9 as well as 3.4.5. Looks like it's present in 2.7.2 and 3.5.2 as well:

https://github.com/charles-uno/python-new-pool-bug/issues/1
History
Date User Action Args
2017-04-07 17:25:19Charles McEachernsetrecipients: + Charles McEachern
2017-04-07 17:25:19Charles McEachernsetmessageid: <1491585919.25.0.878478189526.issue30018@psf.upfronthosting.co.za>
2017-04-07 17:25:19Charles McEachernlinkissue30018 messages
2017-04-07 17:25:19Charles McEacherncreate