I just ran this code that is an example of serial printing some numbers, and it does the same thing. It gives me an error message on the pi that "resource unavailable, port temporarily unavailable, cannot lock port".
Then, when I unplug the usb cable and plug it back in, the port becomes opened, and it gives me error messages that the numbers are unexpected in json. That part is just fine, and to be accepted, as it doesn't recognize what is being printed to the serial port. It's the "cannot lock port" until I unplug and replug in the usb that is the problem.
Edit: I just tried it with firmata, and it causes the same error, "cannot lock port".