The reason that nothing is printed is because apply_async not working. By the way, I think this is bad behavior that just makes people embarrassed. You can pass error_callback to handle errors.
def errorCallback(exception): print(exception) def userAsyncCall(): pool = Pool() pool.apply_async(doSomething, [1], callback=callbackFunc, error_callback=errorCallback)
When you come here, the exit will be
Error sending result: 'LogEntry(logLev=1, msg='Message Here')'. Reason: 'PicklingError("Can't pickle <class '__mp_main__.LogEntry'>: attribute lookup LogEntry on __mp_main__ failed",)'
PicklingError! You are right, namedtuple cannot be passed from a spawned process to a callback.
This may not be a more affordable way, but you can send a dict as the result instead of namedtuple.
As fixed by Dag Høidahl, namedtuple can be passed. The next line works.
LogEntry = namedtuple("LogEntry", ['logLev', 'msg'])
gzc
source share