Appium capturing screenshot from wrong device

I am running 2 instance of appium server simultaneously on my machine. I have attached 1 android devices to each instance of appium server. scripts are running fine on both device in parallel, but while taking screenshot, instead of same device, another device screenshot is captured.
PS: I have tried setting up different systemPort as defaultCapability but that does not solve the issue.

Environment Appium version : 1.7.1
Desktop OS/version used to run Appium: MAC OS Sierra 10.12.6
Node.js version (unless using|exe): 8.6.0
Mobile platform/version under test: Android 8.0.0 and Android 6.0.1
Real device or emulator/simulator: Real Device
Appium CLI or|exe: Appium Cli

Look like framework implementation issue.
Are you sure threads are isolated and handled in parallel execution?
Need more details on take screenshot implementation part in your framework.