Write logs to buffer before worker exits
Replace module level sock object with function level local variable to prevent a potential risk of sock object being shared by multiple (fake) requests