Error: 'NoneType' object has no attribute 'twophase'