I used PyAudio for recording and sounding.
Both can work respectively, but I couldn't record while sounding.
It always first sound and record or record and sound.
I tried thread but did not work.
You could try the playrec() function from http://python-sounddevice.rtfd.org/.
import sounddevice as sd
myrecording = sd.playrec(myarray, samplerate, channels=2)